Re: [Kgdb-bugreport] [PATCH] 8139too: harden against TX ring overflow

2007-04-05 Thread Amit S. Kale
On Friday 06 April 2007 07:18, Herbert Xu wrote:
> Sergei Shtylyov <[EMAIL PROTECTED]> wrote:
> > This driver's 4-packet deep TX queue is too sensible to the "careless"
> > callers ignoring its state (like netpoll in trapped mode), so add "queue
> > full" check at the start of the hard_start_xmit() method (only under
> > #ifndef RTL8139_NDEBUG, otherwise the queue will get stuck once dirty
> > pointer gets out of sync); switch to using appropriate mnemonics for the
> > return values while at it.
>
> Could you please describe this netpoll scenario in more detail?
> More importantly, why wouldn't we fix netpoll instead?

We're trying to figure out a way of fixing netpoll. Don't know what the 
solution is yet.

Here is what happens: in KGDB we set netpoll trapped flag. This prevents 
stopping and starting of a netdev queue. Interfaces that have a small ring 
(8139) run into a problem because of this. When the ring goes full, it can't 
stop the queue. This doesn't make sense since in absence of ring descriptors, 
the device can't transmit any more packets. Sergie had posted one more patch 
last week that lets us start and stop queues in trapped state.

This patch fixes the 8139 side behavior in this context.
-Amit
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Kgdb-bugreport] [PATCH 2.6.20-rc7] 8139too KGDBoE fix

2007-02-22 Thread Amit S. Kale
Hi Net Gurus,

This thread came up on kgdb-bugreport mailing list. Could you please suggest 
us what's the correct way of fixing this problem?

1. When running a kgdb on RTL8139 ethernet interface: 8139too driver prints 
too many "Out-of-sync dirty pointer" messages on console and gdb can't 
connect to kgdb stub. These messages can be suppressed, though it still 
results in connection failures frequently. 

2. Here is how kgdb uses polling mechanism for communication to gdb.  kgdb 
calls netpoll_set_trap(1) just before entering a loop where it communicates 
to gdb. It calls netpoll_set_trap(0) after it is done and wants to resume a 
kernel. The communication to gdb goes through netpoll_poll (which calls kgdb 
rx_hook) and netpoll_send_udp functions.

3. A queue for an interface may have been stopped by it's driver by calling 
netif_stop_queue. After this if kgdb attempts to enter communication with 
gdb, it'll call netpoll_set_trap(1), after which the queue can't be started 
again. This is a potential deadlock situation. Is there a way out of this?

4. Is it necessary to call netpoll_set_trap(1) at all before entering gdb 
communication loop? Even if a driver stops the queue in middle of the 
communication netpoll_poll and netpoll_send_udp calls can recover from that 
by calling driver's interrupt and poll routines. Is this a valid statement?

Thanks a lot.
-Amit



On Thursday 22 February 2007 22:11, Sergei Shtylyov wrote:
> Hello, I wrote:
> >>>Even with this patch, the packets probably get stuck somewhere in
> >>> the driver, as cross-gdb sees tail of the $g packet reply only in
> >>> reply to next packet...
> >>>
> >>>  This wasn;t happeing on x86 probably because the register packet
> >>> should be much shorted there than on PPC...
> >>>
> >>  Argh! That's all because of the CONFIG_NETPOLL_TRAP that
> >>CONFIG_KGDBOE* options select -- since the initial breakpoint enables
> >>trapping via KGDBoE's pre_exception() handler,
> >> netif_{stop/wake}_queue() stop to work and that causes KGDBoE to
> >> literally flood 8139too with packets (although it can't queue up
> >> more than 4). Looks like a general design issue to me... :-/
> >
> > Well, maybe not. But many drivers are surely unprepared to their
> >hard_start_xmit() method being called with queue alraedy stopped and
> >those with small TX queue (like natsemi with which we're also having
> >trouble) would get flooded as well. I'm going to submit a patch to
> >netdev adding extra check for TX ring being full -- after/if it gets
> >accepted, this patch won't be needed anymore.
> 
> Here is what comes to my mind right away. It might need some more
> polishing or cleaning up:
> 
> A potential solution will be to check the if hard_start_xmit() returns
> NETDEV_TX_BUSY. In case transmit queue is busy (due to lot of threads
>  or queue getting full), we should wait in netpoll_send_skb(), call a
>  cleanup through poll() and then retry sending packet.
> >>>
> >>>   This is already being done by netpoll iself. The thing is that
> >>>hard_start_xmit() doesdn't return NETDEV_TX_BUSY in those drivers. :-/
> >>
> >>In addition to that we set trapped. I wonder whether it is possible that
> >> a queue is stopped and we enter kgdb. It would be a deadlock.
> >>-Amit
> >
> > Why? Netpoll does call the driver's interrupt and NAPI handlers in
> > that case (until the retry count is 0).
>
> Ah, got it -- since the traffic trapping (when enabled) effectively
> bypasses netif_wake_queue(), a queue would never be actually woken up.
> Maybe it's worth to always return 0 from netif_queue_stopped() in this
> case? Or maybe the correct thing to do when trapping is to just thiddle the
> __LINK_STATE_XOFF bit, bypassing call to netif_schedule()?
>
> Regards,
> Mithlesh Thukral
>
> WBR, Sergei
>
> -
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ___
> Kgdb-bugreport mailing list
> Kgdb-bugreport@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] NetXen: Driver ifconfig fix

2007-02-21 Thread Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

---

 netxen_nic_main.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index b2fc2bc..1bf3d49 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -525,6 +525,8 @@ static void __devexit netxen_nic_remove(
if (adapter == NULL)
return;
 
+   if (adapter->irq)
+   free_irq(adapter->irq, adapter);
netxen_nic_stop_all_ports(adapter);
/* leave the hw in the same state as reboot */
netxen_pinit_from_rom(adapter, 0);
@@ -672,8 +674,6 @@ static int netxen_nic_close(struct net_d
 
if (!adapter->active_ports) {
netxen_nic_disable_int(adapter);
-   if (adapter->irq)
-   free_irq(adapter->irq, adapter);
cmd_buff = adapter->cmd_buf_arr;
for (i = 0; i < adapter->max_tx_desc_count; i++) {
buffrag = cmd_buff->frag_array;
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] NetXen: Driver unload fixes

2007-02-21 Thread Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

---

My apologizes for sending patch with wrong order/number of patches in subject 
line.
Now I am resending both the patches with correct line.

Thanks,
--Amit

 netxen_nic_hw.c   |9 +
 netxen_nic_main.c |2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic_hw.c 
b/drivers/net/netxen/netxen_nic_hw.c
index 7195af3..deec796 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -242,10 +242,11 @@ int netxen_nic_hw_resources(struct netxe
adapter->cmd_consumer = (uint32_t *) (((char *)addr) +
  sizeof(struct netxen_ring_ctx));
 
-   addr = pci_alloc_consistent(adapter->ahw.pdev,
-   sizeof(struct cmd_desc_type0) *
-   adapter->max_tx_desc_count,
-   (dma_addr_t *) & hw->cmd_desc_phys_addr);
+   addr = netxen_alloc(adapter->ahw.pdev,
+   sizeof(struct cmd_desc_type0) *
+   adapter->max_tx_desc_count,
+   (dma_addr_t *) & hw->cmd_desc_phys_addr,
+   &adapter->ahw.cmd_desc_pdev);
printk("cmd_desc_phys_addr: 0x%llx\n", (u64) hw->cmd_desc_phys_addr);
 
if (addr == NULL) {
diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index 225ff55..b2fc2bc 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -1155,8 +1155,8 @@ static void __exit netxen_exit_module(vo
/*
 * Wait for some time to allow the dma to drain, if any.
 */
-   destroy_workqueue(netxen_workq);
pci_unregister_driver(&netxen_driver);
+   destroy_workqueue(netxen_workq);
 }
 
 module_exit(netxen_exit_module);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/1] NetXen: Driver unload fixes

2007-02-21 Thread Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

---

 netxen_nic_hw.c   |9 +
 netxen_nic_main.c |2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic_hw.c 
b/drivers/net/netxen/netxen_nic_hw.c
index 7195af3..deec796 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -242,10 +242,11 @@ int netxen_nic_hw_resources(struct netxe
adapter->cmd_consumer = (uint32_t *) (((char *)addr) +
  sizeof(struct netxen_ring_ctx));
 
-   addr = pci_alloc_consistent(adapter->ahw.pdev,
-   sizeof(struct cmd_desc_type0) *
-   adapter->max_tx_desc_count,
-   (dma_addr_t *) & hw->cmd_desc_phys_addr);
+   addr = netxen_alloc(adapter->ahw.pdev,
+   sizeof(struct cmd_desc_type0) *
+   adapter->max_tx_desc_count,
+   (dma_addr_t *) & hw->cmd_desc_phys_addr,
+   &adapter->ahw.cmd_desc_pdev);
printk("cmd_desc_phys_addr: 0x%llx\n", (u64) hw->cmd_desc_phys_addr);
 
if (addr == NULL) {
diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index 225ff55..b2fc2bc 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -1155,8 +1155,8 @@ static void __exit netxen_exit_module(vo
/*
 * Wait for some time to allow the dma to drain, if any.
 */
-   destroy_workqueue(netxen_workq);
pci_unregister_driver(&netxen_driver);
+   destroy_workqueue(netxen_workq);
 }
 
 module_exit(netxen_exit_module);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] NetXen: 1G/10G Ethernet Driver updates

2007-02-21 Thread Amit S. Kale
I will be sending NetXen: 1G/10G Ethernet Driver updates with respect to 
netdev #upstream in the subsequent emails.

Thanks,
--Amit
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] NetXen: Fix to get the driver working after sparse changes

2007-02-12 Thread Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

---
 netxen_nic.h |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index e021a30..2807ef4 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -252,7 +252,7 @@ typedef u32 netxen_ctx_msg;
 #define netxen_set_msg_ctxid(config_word, val) \
((config_word) &= ~(0x3ff<<18), (config_word) |= (val & 0x3ff) << 18)
 #define netxen_set_msg_opcode(config_word, val)\
-   ((config_word) &= ~(0xf<<24), (config_word) |= (val & 0xf) << 24)
+   ((config_word) &= ~(0xf<<28), (config_word) |= (val & 0xf) << 28)
 
 struct netxen_rcv_context {
__le64 rcv_ring_addr;
@@ -303,14 +303,14 @@ struct netxen_ring_ctx {
(cmd_desc)->flags_opcode |= cpu_to_le16((val) & 0x7f))
 #define netxen_set_cmd_desc_opcode(cmd_desc, val)  \
((cmd_desc)->flags_opcode &= ~cpu_to_le16(0x3f<<7), \
-   (cmd_desc)->flags_opcode |= cpu_to_le16((val) & (0x3f<<7)))
+   (cmd_desc)->flags_opcode |= cpu_to_le16(((val & 0x3f)<<7)))
 
 #define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \
((cmd_desc)->num_of_buffers_total_length &= ~cpu_to_le32(0xff), \
(cmd_desc)->num_of_buffers_total_length |= cpu_to_le32((val) & 0xff))
 #define netxen_set_cmd_desc_totallength(cmd_desc, val) \
-   ((cmd_desc)->num_of_buffers_total_length &= cpu_to_le32(0xff), \
-   (cmd_desc)->num_of_buffers_total_length |= cpu_to_le32(val << 24))
+   ((cmd_desc)->num_of_buffers_total_length &= ~cpu_to_le32(0xff00), \
+   (cmd_desc)->num_of_buffers_total_length |= cpu_to_le32(val << 8))
 
 #define netxen_get_cmd_desc_opcode(cmd_desc)   \
((le16_to_cpu((cmd_desc)->flags_opcode) >> 7) & 0x003F)
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] NetXen: Updates for ethtool support

2007-02-09 Thread Amit S. Kale
NetXen: Updates for ethtool support.

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

---

 netxen_nic.h |1 +
 netxen_nic_ethtool.c |9 +
 netxen_nic_init.c|8 
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 3f3896e..e021a30 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -1040,6 +1040,7 @@ int netxen_flash_unlock(struct netxen_ad
 int netxen_backup_crbinit(struct netxen_adapter *adapter);
 int netxen_flash_erase_secondary(struct netxen_adapter *adapter);
 int netxen_flash_erase_primary(struct netxen_adapter *adapter);
+void netxen_halt_pegs(struct netxen_adapter *adapter);
 
 int netxen_rom_fast_write(struct netxen_adapter *adapter, int addr, int data);
 int netxen_rom_se(struct netxen_adapter *adapter, int addr);
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c 
b/drivers/net/netxen/netxen_nic_ethtool.c
index cc0efe2..6252e9a 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -402,7 +402,7 @@ netxen_nic_get_wol(struct net_device *de
wol->wolopts = 0;
 }
 
-static u32 netxen_nic_get_link(struct net_device *dev)
+static u32 netxen_nic_test_link(struct net_device *dev)
 {
struct netxen_port *port = netdev_priv(dev);
struct netxen_adapter *adapter = port->adapter;
@@ -459,6 +459,7 @@ netxen_nic_set_eeprom(struct net_device 
int ret;
 
if (flash_start == 0) {
+   netxen_halt_pegs(adapter);
ret = netxen_flash_unlock(adapter);
if (ret < 0) {
printk(KERN_ERR "%s: Flash unlock failed.\n",
@@ -712,7 +713,7 @@ netxen_nic_diag_test(struct net_device *
 {
if (eth_test->flags == ETH_TEST_FL_OFFLINE) {   /* offline tests */
/* link test */
-   if (!(data[4] = (u64) netxen_nic_get_link(dev)))
+   if (!(data[4] = (u64) netxen_nic_test_link(dev)))
eth_test->flags |= ETH_TEST_FL_FAILED;
 
if (netif_running(dev))
@@ -727,7 +728,7 @@ netxen_nic_diag_test(struct net_device *
dev->open(dev);
} else {/* online tests */
/* link test */
-   if (!(data[4] = (u64) netxen_nic_get_link(dev)))
+   if (!(data[4] = (u64) netxen_nic_test_link(dev)))
eth_test->flags |= ETH_TEST_FL_FAILED;
 
/* other tests pass by default */
@@ -783,7 +784,7 @@ struct ethtool_ops netxen_nic_ethtool_op
.get_regs_len = netxen_nic_get_regs_len,
.get_regs = netxen_nic_get_regs,
.get_wol = netxen_nic_get_wol,
-   .get_link = netxen_nic_get_link,
+   .get_link = ethtool_op_get_link,
.get_eeprom_len = netxen_nic_get_eeprom_len,
.get_eeprom = netxen_nic_get_eeprom,
.set_eeprom = netxen_nic_set_eeprom,
diff --git a/drivers/net/netxen/netxen_nic_init.c 
b/drivers/net/netxen/netxen_nic_init.c
index c243c16..2f32436 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -717,6 +717,14 @@ netxen_flash_erase_primary(struct netxen
return ret;
 }
 
+void netxen_halt_pegs(struct netxen_adapter *adapter)
+{
+netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0x3c, 1);
+netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0x3c, 1);
+netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0x3c, 1);
+netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0x3c, 1);
+}
+
 int netxen_flash_unlock(struct netxen_adapter *adapter)
 {
int ret = 0;
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] NetXen: Fixes for ppc architecture.

2007-02-09 Thread Amit S. Kale
NetXen: Fixes for ppc architecture.

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

---

 netxen_nic_hw.c   |2 ++
 netxen_nic_init.c |4 ++--
 netxen_nic_main.c |3 ++-
 netxen_nic_niu.c  |2 +-
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic_hw.c 
b/drivers/net/netxen/netxen_nic_hw.c
index f263232..7195af3 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -420,6 +420,7 @@ static int netxen_get_flash_block(struct
for (i = 0; i < size / sizeof(u32); i++) {
if (netxen_rom_fast_read(adapter, addr, ptr32) == -1)
return -1;
+   *ptr32 = cpu_to_le32(*ptr32);
ptr32++;
addr += sizeof(u32);
}
@@ -428,6 +429,7 @@ static int netxen_get_flash_block(struct
 
if (netxen_rom_fast_read(adapter, addr, &local) == -1)
return -1;
+   local = cpu_to_le32(local);
memcpy(ptr32, &local, (char *)buf + size - (char *)ptr32);
}
 
diff --git a/drivers/net/netxen/netxen_nic_init.c 
b/drivers/net/netxen/netxen_nic_init.c
index f7bb8c9..c243c16 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -1246,7 +1246,7 @@ int netxen_process_cmd_ring(unsigned lon
 * the netdev which is associated with that device.
 */
 
-   consumer = *(adapter->cmd_consumer);
+   consumer = le32_to_cpu(*(adapter->cmd_consumer));
if (last_consumer == consumer) {/* Ring is empty*/
DPRINTK(INFO, "last_consumer %d == consumer %d\n",
last_consumer, consumer);
@@ -1340,7 +1340,7 @@ int netxen_process_cmd_ring(unsigned lon
if (adapter->last_cmd_consumer == consumer &&
(((adapter->cmd_producer + 1) %
  adapter->max_tx_desc_count) == adapter->last_cmd_consumer)) {
-   consumer = *(adapter->cmd_consumer);
+   consumer = le32_to_cpu(*(adapter->cmd_consumer));
}
done = (adapter->last_cmd_consumer == consumer);
 
diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index 69c1b9d..c2da7ec 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -434,12 +434,13 @@ #endif
adapter->port_count++;
adapter->port[i] = port;
}
-
+#ifndef CONFIG_PPC64
writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
netxen_pinit_from_rom(adapter, 0);
udelay(500);
netxen_load_firmware(adapter);
netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
+#endif
/*
 * delay a while to ensure that the Pegs are up & running.
 * Otherwise, we might see some flaky behaviour.
diff --git a/drivers/net/netxen/netxen_nic_niu.c 
b/drivers/net/netxen/netxen_nic_niu.c
index 40d7003..d5d9507 100644
--- a/drivers/net/netxen/netxen_nic_niu.c
+++ b/drivers/net/netxen/netxen_nic_niu.c
@@ -458,7 +458,7 @@ int netxen_niu_gbe_init_port(struct netx
 
 int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port)
 {
-   long reg = 0, ret = 0;
+   u32 reg = 0, ret = 0;
 
if (adapter->ahw.boardcfg.board_type == 
NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) {
netxen_crb_writelit_adapter(adapter,
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] NetXen: 1G/10G Ethernet Driver updates

2007-02-09 Thread Amit S. Kale
Hi All,

I will be sending NetXen: 1G/10G Ethernet Driver updates with respect to 
netdev #upstream in the subsequent emails.

Thanks,
--Amit
~

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


[PATCH 3/3] NetXen: Added ethtool support for user level tools.

2007-02-05 Thread Amit S. Kale
NetXen: Added ethtool support for user level firmware management utilities.

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

---

 netxen_nic.h |   17 ++-
 netxen_nic_ethtool.c |   96 +++---
 netxen_nic_init.c|  267++-
 3 files changed, 361 insertions(+), 19 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index d689476..741c64c 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -63,11 +63,14 @@ #include 
 
 #include "netxen_nic_hw.h"
 
-#define NETXEN_NIC_BUILD_NO "2"
 #define _NETXEN_NIC_LINUX_MAJOR 3
 #define _NETXEN_NIC_LINUX_MINOR 3
 #define _NETXEN_NIC_LINUX_SUBVERSION 3
-#define NETXEN_NIC_LINUX_VERSIONID  "3.3.3" "-" NETXEN_NIC_BUILD_NO
+#define NETXEN_NIC_LINUX_VERSIONID  "3.3.3"
+
+#define NUM_FLASH_SECTORS (64)
+#define FLASH_SECTOR_SIZE (64 * 1024)
+#define FLASH_TOTAL_SIZE  (NUM_FLASH_SECTORS * FLASH_SECTOR_SIZE)
 
 #define RCV_DESC_RINGSIZE  \
(sizeof(struct rcv_desc) * adapter->max_rx_desc_count)
@@ -85,6 +88,7 @@ #define NETXEN_NETDEV_STATUS  0x1
 #define NETXEN_RCV_PRODUCER_OFFSET 0
 #define NETXEN_RCV_PEG_DB_ID   2
 #define NETXEN_HOST_DUMMY_DMA_SIZE 1024
+#define FLASH_SUCCESS 0
 
 #define ADDR_IN_WINDOW1(off)   \
((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0
@@ -1054,6 +1058,15 @@ void netxen_phantom_init(struct netxen_a
 void netxen_load_firmware(struct netxen_adapter *adapter);
 int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
 int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp);
+int netxen_rom_fast_read_words(struct netxen_adapter *adapter, int addr, 
+   u8 *bytes, size_t size);
+int netxen_rom_fast_write_words(struct netxen_adapter *adapter, int addr, 
+   u8 *bytes, size_t size);
+int netxen_flash_unlock(struct netxen_adapter *adapter);
+int netxen_backup_crbinit(struct netxen_adapter *adapter);
+int netxen_flash_erase_secondary(struct netxen_adapter *adapter);
+int netxen_flash_erase_primary(struct netxen_adapter *adapter);
+
 int netxen_rom_fast_write(struct netxen_adapter *adapter, int addr, int data);
 int netxen_rom_se(struct netxen_adapter *adapter, int addr);
 int netxen_do_rom_se(struct netxen_adapter *adapter, int addr);
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c 
b/drivers/net/netxen/netxen_nic_ethtool.c
index 3404461..aa96140 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -32,6 +32,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -94,17 +95,7 @@ #define NETXEN_MAX_EEPROM_LEN   1024
 
 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 & NETXEN_ROM_ROUNDUP)) {
-   n &= ~NETXEN_ROM_ROUNDUP;
-   if (n < NETXEN_MAX_EEPROM_LEN)
-   return n;
-   }
-   return 0;
+   return FLASH_TOTAL_SIZE;
 }
 
 static void
@@ -440,18 +431,92 @@ netxen_nic_get_eeprom(struct net_device 
struct netxen_port *port = netdev_priv(dev);
struct netxen_adapter *adapter = port->adapter;
int offset;
+   int ret;
 
if (eeprom->len == 0)
return -EINVAL;
 
eeprom->magic = (port->pdev)->vendor | ((port->pdev)->device << 16);
-   for (offset = 0; offset < eeprom->len; offset++)
-   if (netxen_rom_fast_read
-   (adapter, (8 * offset) + 8, (int *)eeprom->data) == -1)
-   return -EIO;
+   offset = eeprom->offset;
+
+   ret = netxen_rom_fast_read_words(adapter, offset, bytes, 
+   eeprom->len);
+   if (ret < 0)
+   return ret;
+
return 0;
 }
 
+static int
+netxen_nic_set_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 = eeprom->offset;
+   static int flash_start;
+   static int ready_to_flash;
+   int ret;
+
+   if (flash_start == 0) {
+   ret = netxen_flash_unlock(adapter);
+   if (ret < 0) {
+   printk(KERN_ERR "%s: Flash unlock failed.\n",
+   netxen_nic_driver_name);
+   return ret;
+   }
+   printk(KERN_INFO "%s: flash unlocked. \n", 
+   netxen_nic_dr

[PATCH 2/3] NetXen: Firmware crb init changes.

2007-02-05 Thread Amit S. Kale
NetXen: firmware crb init changes.

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

---

 netxen_nic_init.c |   12 +---
 1 files changed, 9 insertions(+), 3 deletions(-)
  
diff --git a/drivers/net/netxen/netxen_nic_init.c 
b/drivers/net/netxen/netxen_nic_init.c
index ec1c736..73c0c45 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -110,6 +110,7 @@ static void crb_addr_transform_setup(voi
crb_addr_transform(CAM);
crb_addr_transform(C2C1);
crb_addr_transform(C2C0);
+   crb_addr_transform(SMB);
 }
 
 int netxen_init_firmware(struct netxen_adapter *adapter)
@@ -543,9 +544,13 @@ int netxen_pinit_from_rom(struct netxen_
}
for (i = 0; i < n; i++) {
 
-   off =
-   netxen_decode_crb_addr((unsigned long)buf[i].addr) +
-   NETXEN_PCI_CRBSPACE;
+   off = netxen_decode_crb_addr((unsigned 
long)buf[i].addr);
+   if (off == NETXEN_ADDR_ERROR) {
+   printk(KERN_ERR"CRB init value out of range 
%lx\n",
+   buf[i].addr);
+   continue;
+   }
+   off += NETXEN_PCI_CRBSPACE;
/* skipping cold reboot MAGIC */
if (off == NETXEN_CAM_RAM(0x1fc))
continue;
@@ -662,6 +667,7 @@ void netxen_phantom_init(struct netxen_a
int loops = 0;
 
if (!pegtune_val) {
+   val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
while (val != PHAN_INITIALIZE_COMPLETE && loops < 20) {
udelay(100);
schedule();
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] NetXen: Fixes for ppc architecture.

2007-02-05 Thread Amit S. Kale
NetXen: Fixes for ppc architecture.

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

---

 netxen_nic.h  |   98 --
 netxen_nic_hw.c   |   31 -
 netxen_nic_init.c |   16 
 netxen_nic_main.c |7 ++-
 netxen_nic_niu.c  |2 -
 5 files changed, 89 insertions(+), 65 deletions(-)
  
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 59324b1..d689476 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -246,6 +246,18 @@ #define _netxen_set_bits(config_word, st
(config_word) |= (((value) << (start)) & mask); \
 }
 
+static inline u32 netxen_set_32bits(u32 config_word, int start,
+ int bits, u32 val)
+{
+   _netxen_set_bits(config_word, start, bits, val);
+   return config_word;
+}
+static inline u16 netxen_set_16bits(u16 config_word, int start,
+ int bits, u16 val)
+{
+   _netxen_set_bits(config_word, start, bits, val);
+   return config_word;
+}
 #define netxen_set_msg_peg_id(config_word, val)\
_netxen_set_bits(config_word, 0, 2, val)
 #define netxen_set_msg_privid(config_word) \
@@ -305,69 +317,77 @@ #define netxen_set_cmd_desc_port(cmd_des
((cmd_desc)->port_ctxid |= ((var) & 0x0F))
 
 #define netxen_set_cmd_desc_flags(cmd_desc, val)   \
-   _netxen_set_bits((cmd_desc)->flags_opcode, 0, 7, val)
+   (cmd_desc)->flags_opcode = cpu_to_le16( \
+   netxen_set_16bits(le16_to_cpu((cmd_desc)->flags_opcode), 0, 7, val))
+
 #define netxen_set_cmd_desc_opcode(cmd_desc, val)  \
-   _netxen_set_bits((cmd_desc)->flags_opcode, 7, 6, val)
+   (cmd_desc)->flags_opcode = cpu_to_le16( \
+   netxen_set_16bits(le16_to_cpu((cmd_desc)->flags_opcode), 7, 6, val))
 
 #define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \
-   _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 0, 8, val);
+   (cmd_desc)->num_of_buffers_total_length = cpu_to_le32(  \
+   netxen_set_32bits(le32_to_cpu((cmd_desc)->num_of_buffers_total_length), 
\
+ 0, 8, val))
+
 #define netxen_set_cmd_desc_totallength(cmd_desc, val) \
-   _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 8, 24, val);
+   (cmd_desc)->num_of_buffers_total_length = cpu_to_le32(  \
+   netxen_set_32bits(le32_to_cpu((cmd_desc)->num_of_buffers_total_length), 
\
+ 8, 24, val))
 
 #define netxen_get_cmd_desc_opcode(cmd_desc)   \
-   (((cmd_desc)->flags_opcode >> 7) & 0x003F)
+   ((le16_to_cpu((cmd_desc)->flags_opcode) >> 7) & 0x003F)
 #define netxen_get_cmd_desc_totallength(cmd_desc)  \
-   (((cmd_desc)->num_of_buffers_total_length >> 8) & 0x0FF)
+   ((le32_to_cpu((cmd_desc)->num_of_buffers_total_length) >> 8) & 
0x0FF)
 
 struct cmd_desc_type0 {
u8 tcp_hdr_offset;  /* For LSO only */
u8 ip_hdr_offset;   /* For LSO only */
/* Bit pattern: 0-6 flags, 7-12 opcode, 13-15 unused */
-   u16 flags_opcode;
+   __le16 flags_opcode;
/* Bit pattern: 0-7 total number of segments,
   8-31 Total size of the packet */
-   u32 num_of_buffers_total_length;
+   __le32 num_of_buffers_total_length;
union {
struct {
-   u32 addr_low_part2;
-   u32 addr_high_part2;
+   __le32 addr_low_part2;
+   __le32 addr_high_part2;
};
-   u64 addr_buffer2;
+   __le64 addr_buffer2;
};
 
-   u16 reference_handle;   /* changed to u16 to add mss */
-   u16 mss;/* passed by NDIS_PACKET for LSO */
+   __le16 reference_handle;/* changed to u16 to add mss */
+   __le16 mss; /* passed by NDIS_PACKET for LSO */
/* Bit pattern 0-3 port, 0-3 ctx id */
u8 port_ctxid;
u8 total_hdr_length;/* LSO only : MAC+IP+TCP Hdr size */
-   u16 conn_id;/* IPSec offoad only */
+   __le16 conn_id; /* IPSec offoad only */
 
union {
struct {
-   u32 addr_low_part3;
-   u32 addr_high_part3;
+   __le32 addr_low_part3;
+   __le32 addr_high_part3;
};
-   u64 addr_buffer3;
+   __le64 addr_buffer3;
};
union {
struct {
-   u32 addr_low_part1;
-   u32 addr_high_part1;
+   __le32 addr_low_part1;
+   __le32 addr_high_part1;
};
-   u64 addr_buffer1;
+   __le64 addr_buffer1;
};
 
-   u16 buffer1_length;
-   u16 buffer

[PATCH 0/3] NetXen: 1G/10G Ethernet Driver updates

2007-02-05 Thread Amit S. Kale
Hi All,

I will be sending NetXen: 1G/10G Ethernet Driver updates with respect to 
netdev #master in the subsequent emails.

We have incorporated the feedbacks we got for the patch on the ethtool 
support for user level tools, except for these:

Jeff Garzik wrote:
>is it ok to return without re-locking flash?

After flashing, we have to reboot the machine before we can use
the newer flash. So re-locking is not necessary.
Also its not possible to detect the end of flashing process, so as 
to lock the flash after that.

>>   netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
>> - udelay(100);/* prevent bursting on CRB */
>> + udelay(70); /* prevent bursting on CRB */
Jeff Garzik wrote:
>why?

This is only to reduce the flashing time.

Thanks,
--Amit
~

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


[PATCH 1/1] NetXen: Fixes for ppc architecture.

2007-01-31 Thread Amit S. Kale
NetXen: Fixes for ppc architecture.

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

---

Sorry, I wanted to send only one patch so please ignore [PATCH 0/2] in the
subject of my last mail. It should be [PATCH 0/1].

 netxen_nic.h  |   98 --
 netxen_nic_hw.c   |   31 -
 netxen_nic_init.c |   19 +-
 netxen_nic_main.c |7 ++-
 netxen_nic_niu.c  |2 -
 5 files changed, 91 insertions(+), 66 deletions(-)
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 59324b1..d689476 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -246,6 +246,18 @@ #define _netxen_set_bits(config_word, st
(config_word) |= (((value) << (start)) & mask); \
 }
 
+static inline u32 netxen_set_32bits(u32 config_word, int start,
+ int bits, u32 val)
+{
+   _netxen_set_bits(config_word, start, bits, val);
+   return config_word;
+}
+static inline u16 netxen_set_16bits(u16 config_word, int start,
+ int bits, u16 val)
+{
+   _netxen_set_bits(config_word, start, bits, val);
+   return config_word;
+}
 #define netxen_set_msg_peg_id(config_word, val)\
_netxen_set_bits(config_word, 0, 2, val)
 #define netxen_set_msg_privid(config_word) \
@@ -305,69 +317,77 @@ #define netxen_set_cmd_desc_port(cmd_des
((cmd_desc)->port_ctxid |= ((var) & 0x0F))
 
 #define netxen_set_cmd_desc_flags(cmd_desc, val)   \
-   _netxen_set_bits((cmd_desc)->flags_opcode, 0, 7, val)
+   (cmd_desc)->flags_opcode = cpu_to_le16( \
+   netxen_set_16bits(le16_to_cpu((cmd_desc)->flags_opcode), 0, 7, val))
+
 #define netxen_set_cmd_desc_opcode(cmd_desc, val)  \
-   _netxen_set_bits((cmd_desc)->flags_opcode, 7, 6, val)
+   (cmd_desc)->flags_opcode = cpu_to_le16( \
+   netxen_set_16bits(le16_to_cpu((cmd_desc)->flags_opcode), 7, 6, val))
 
 #define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \
-   _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 0, 8, val);
+   (cmd_desc)->num_of_buffers_total_length = cpu_to_le32(  \
+   netxen_set_32bits(le32_to_cpu((cmd_desc)->num_of_buffers_total_length), 
\
+ 0, 8, val))
+
 #define netxen_set_cmd_desc_totallength(cmd_desc, val) \
-   _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 8, 24, val);
+   (cmd_desc)->num_of_buffers_total_length = cpu_to_le32(  \
+   netxen_set_32bits(le32_to_cpu((cmd_desc)->num_of_buffers_total_length), 
\
+ 8, 24, val))
 
 #define netxen_get_cmd_desc_opcode(cmd_desc)   \
-   (((cmd_desc)->flags_opcode >> 7) & 0x003F)
+   ((le16_to_cpu((cmd_desc)->flags_opcode) >> 7) & 0x003F)
 #define netxen_get_cmd_desc_totallength(cmd_desc)  \
-   (((cmd_desc)->num_of_buffers_total_length >> 8) & 0x0FF)
+   ((le32_to_cpu((cmd_desc)->num_of_buffers_total_length) >> 8) & 
0x0FF)
 
 struct cmd_desc_type0 {
u8 tcp_hdr_offset;  /* For LSO only */
u8 ip_hdr_offset;   /* For LSO only */
/* Bit pattern: 0-6 flags, 7-12 opcode, 13-15 unused */
-   u16 flags_opcode;
+   __le16 flags_opcode;
/* Bit pattern: 0-7 total number of segments,
   8-31 Total size of the packet */
-   u32 num_of_buffers_total_length;
+   __le32 num_of_buffers_total_length;
union {
struct {
-   u32 addr_low_part2;
-   u32 addr_high_part2;
+   __le32 addr_low_part2;
+   __le32 addr_high_part2;
};
-   u64 addr_buffer2;
+   __le64 addr_buffer2;
};
 
-   u16 reference_handle;   /* changed to u16 to add mss */
-   u16 mss;/* passed by NDIS_PACKET for LSO */
+   __le16 reference_handle;/* changed to u16 to add mss */
+   __le16 mss; /* passed by NDIS_PACKET for LSO */
/* Bit pattern 0-3 port, 0-3 ctx id */
u8 port_ctxid;
u8 total_hdr_length;/* LSO only : MAC+IP+TCP Hdr size */
-   u16 conn_id;/* IPSec offoad only */
+   __le16 conn_id; /* IPSec offoad only */
 
union {
struct {
-   u32 addr_low_part3;
-   u32 addr_high_part3;
+   __le32 addr_low_part3;
+   __le32 addr_high_part3;
};
-   u64 addr_buffer3;
+   __le64 addr_buffer3;
};
union {
struct {
-   u32 addr_low_part1;
-   u32 addr_high_part1;
+   __le32 addr_low_part1;
+   __le32 addr_high_part1;
};
-   

[PATCH 0/2] NetXen: NetXen 1G/10G Ethernet Driver update

2007-01-31 Thread Amit S. Kale
Hi All,

I will be sending NetXen: 1G/10G Ethernet Driver update for ppc fix in the 
subsequent email.
I will send the update for flash code later.

Thanks,
--Amit
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] NetXen: Firmware crb init changes

2007-01-30 Thread Amit S. Kale
NetXen: firmware crb init changes.

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

---

 netxen_nic.h  |2 +-
 netxen_nic_init.c |   12 +---
 2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index f188b59..9964f56 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -63,7 +63,7 @@ #include 
 
 #include "netxen_nic_hw.h"
 
-#define NETXEN_NIC_BUILD_NO "3"
+#define NETXEN_NIC_BUILD_NO "4"
 #define _NETXEN_NIC_LINUX_MAJOR 3
 #define _NETXEN_NIC_LINUX_MINOR 3
 #define _NETXEN_NIC_LINUX_SUBVERSION 3
diff --git a/drivers/net/netxen/netxen_nic_init.c 
b/drivers/net/netxen/netxen_nic_init.c
index 069436f..cdbaf1d 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -110,6 +110,7 @@ static void crb_addr_transform_setup(voi
crb_addr_transform(CAM);
crb_addr_transform(C2C1);
crb_addr_transform(C2C0);
+   crb_addr_transform(SMB);
 }
 
 int netxen_init_firmware(struct netxen_adapter *adapter)
@@ -803,9 +804,13 @@ int netxen_pinit_from_rom(struct netxen_
}
for (i = 0; i < n; i++) {
 
-   off =
-   netxen_decode_crb_addr((unsigned long)buf[i].addr) +
-   NETXEN_PCI_CRBSPACE;
+   off = netxen_decode_crb_addr((unsigned 
long)buf[i].addr);
+   if (off == NETXEN_ADDR_ERROR) {
+   printk(KERN_ERR"CRB init value out of range 
%lx\n",
+   buf[i].addr);
+   continue;
+   }
+   off += NETXEN_PCI_CRBSPACE;
/* skipping cold reboot MAGIC */
if (off == NETXEN_CAM_RAM(0x1fc))
continue;
@@ -922,6 +927,7 @@ void netxen_phantom_init(struct netxen_a
int loops = 0;
 
if (!pegtune_val) {
+   val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
while (val != PHAN_INITIALIZE_COMPLETE && loops < 20) {
udelay(100);
schedule();
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] NetXen: Added ethtool support for user level tools

2007-01-30 Thread Amit S. Kale
Added ethtool support for user level firmware management utilities.

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

---

 netxen_nic.h |   16 ++-
 netxen_nic_ethtool.c |   87 +---
 netxen_nic_init.c|  268 ++-
 3 files changed, 351 insertions(+), 20 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 59324b1..f188b59 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -63,12 +63,16 @@ #include 
 
 #include "netxen_nic_hw.h"
 
-#define NETXEN_NIC_BUILD_NO "2"
+#define NETXEN_NIC_BUILD_NO "3"
 #define _NETXEN_NIC_LINUX_MAJOR 3
 #define _NETXEN_NIC_LINUX_MINOR 3
 #define _NETXEN_NIC_LINUX_SUBVERSION 3
 #define NETXEN_NIC_LINUX_VERSIONID  "3.3.3" "-" NETXEN_NIC_BUILD_NO
 
+#define NUM_FLASH_SECTORS (64)
+#define FLASH_SECTOR_SIZE (64*1024)
+#define FLASH_TOTAL_SIZE  (NUM_FLASH_SECTORS*FLASH_SECTOR_SIZE)
+
 #define RCV_DESC_RINGSIZE  \
(sizeof(struct rcv_desc) * adapter->max_rx_desc_count)
 #define STATUS_DESC_RINGSIZE   \
@@ -85,6 +89,7 @@ #define NETXEN_NETDEV_STATUS  0x1
 #define NETXEN_RCV_PRODUCER_OFFSET 0
 #define NETXEN_RCV_PEG_DB_ID   2
 #define NETXEN_HOST_DUMMY_DMA_SIZE 1024
+#define FLASH_SUCCESS 0
 
 #define ADDR_IN_WINDOW1(off)   \
((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0
@@ -1034,6 +1039,15 @@ void netxen_phantom_init(struct netxen_a
 void netxen_load_firmware(struct netxen_adapter *adapter);
 int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
 int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp);
+int netxen_rom_fast_read_words(struct netxen_adapter *adapter, int addr, 
+   u8 *bytes, size_t size);
+int netxen_rom_fast_write_words(struct netxen_adapter *adapter, int addr, 
+   u8 *bytes, size_t size);
+int netxen_flash_unlock(struct netxen_adapter *adapter);
+int netxen_backup_crbinit(struct netxen_adapter *adapter);
+int netxen_flash_erase_secondary(struct netxen_adapter *adapter);
+int netxen_flash_erase_primary(struct netxen_adapter *adapter);
+
 int netxen_rom_fast_write(struct netxen_adapter *adapter, int addr, int data);
 int netxen_rom_se(struct netxen_adapter *adapter, int addr);
 int netxen_do_rom_se(struct netxen_adapter *adapter, int addr);
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c 
b/drivers/net/netxen/netxen_nic_ethtool.c
index 3404461..49b3b4c 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -32,6 +32,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -94,17 +95,7 @@ #define NETXEN_MAX_EEPROM_LEN   1024
 
 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 & NETXEN_ROM_ROUNDUP)) {
-   n &= ~NETXEN_ROM_ROUNDUP;
-   if (n < NETXEN_MAX_EEPROM_LEN)
-   return n;
-   }
-   return 0;
+   return FLASH_TOTAL_SIZE;
 }
 
 static void
@@ -445,13 +436,78 @@ netxen_nic_get_eeprom(struct net_device 
return -EINVAL;
 
eeprom->magic = (port->pdev)->vendor | ((port->pdev)->device << 16);
-   for (offset = 0; offset < eeprom->len; offset++)
-   if (netxen_rom_fast_read
-   (adapter, (8 * offset) + 8, (int *)eeprom->data) == -1)
-   return -EIO;
+   offset = eeprom->offset;
+
+   if (netxen_rom_fast_read_words
+   (adapter, offset, bytes, eeprom->len) == -1){
+   return -EIO;
+   }
+
return 0;
 }
 
+static int
+netxen_nic_set_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 = eeprom->offset;
+   static int first_write = 1;
+   int ret;
+   static int ready_to_flash = 0;
+
+   if(first_write == 1){
+   netxen_flash_unlock(adapter);
+   printk("%s: flash unlocked. \n", netxen_nic_driver_name);
+   if ((ret = netxen_flash_erase_secondary(adapter)) 
+   != FLASH_SUCCESS) {
+   printk("%s: Flash erase failed.\n", 
+   netxen_nic_driver_name);
+   return(ret);
+   }
+   printk("%s: secondary flash erased successfully.\n", 
+   netxen_nic_driver_name);
+   first_write = 0;
+   

[PATCH 0/2] NetXen: NetXen 1G/10G Ethernet Driver updates

2007-01-30 Thread Amit S. Kale

Hi All,

I will be sending NetXen: 1G/10G Ethernet Driver updates in subsequent emails.

Thanks,
--Amit
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] NetXen: Use pci_register_driver() instead of pci_module_init() in init_module

2007-01-22 Thread Amit S. Kale
I am extremely sorry for sending this patch with wrong subject line before this.
Now i am resending the patch with correct line.

Thanks,
--Amit

This will use pci_register_driver() instead of pci_module_init().

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>
Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>

---
 netxen_nic.h  |2 +-
 netxen_nic_main.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 663fa2f..59324b1 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -63,7 +63,7 @@ #include 
 
 #include "netxen_nic_hw.h"
 
-#define NETXEN_NIC_BUILD_NO "1"
+#define NETXEN_NIC_BUILD_NO "2"
 #define _NETXEN_NIC_LINUX_MAJOR 3
 #define _NETXEN_NIC_LINUX_MINOR 3
 #define _NETXEN_NIC_LINUX_SUBVERSION 3
diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index 8a5792f..96e1bee 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -1144,7 +1144,7 @@ static int __init netxen_init_module(voi
if ((netxen_workq = create_singlethread_workqueue("netxen")) == 0)
return -ENOMEM;
 
-   return pci_module_init(&netxen_driver);
+   return pci_register_driver(&netxen_driver);
 }
 
 module_init(netxen_init_module);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] NetXen: Firmware check modifications

2007-01-22 Thread Amit S. Kale
This will use pci_register_driver() instead of pci_module_init().

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>
Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>

---
 netxen_nic.h  |2 +-
 netxen_nic_main.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 663fa2f..59324b1 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -63,7 +63,7 @@ #include 
 
 #include "netxen_nic_hw.h"
 
-#define NETXEN_NIC_BUILD_NO "1"
+#define NETXEN_NIC_BUILD_NO "2"
 #define _NETXEN_NIC_LINUX_MAJOR 3
 #define _NETXEN_NIC_LINUX_MINOR 3
 #define _NETXEN_NIC_LINUX_SUBVERSION 3
diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index 8a5792f..96e1bee 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -1144,7 +1144,7 @@ static int __init netxen_init_module(voi
if ((netxen_workq = create_singlethread_workqueue("netxen")) == 0)
return -ENOMEM;
 
-   return pci_module_init(&netxen_driver);
+   return pci_register_driver(&netxen_driver);
 }
 
 module_init(netxen_init_module);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] NetXen: Firmware check modifications

2007-01-22 Thread Amit S. Kale
This patch is to make the driver work with multiple minor firmware versions

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

---
 netxen_nic.h|7 +++
 netxen_nic_hw.c |3 ++-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 6490acf..663fa2f 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -63,12 +63,11 @@ #include 
 
 #include "netxen_nic_hw.h"
 
-#define NETXEN_NIC_BUILD_NO "4"
+#define NETXEN_NIC_BUILD_NO "1"
 #define _NETXEN_NIC_LINUX_MAJOR 3
 #define _NETXEN_NIC_LINUX_MINOR 3
-#define _NETXEN_NIC_LINUX_SUBVERSION 2
-#define NETXEN_NIC_LINUX_VERSIONID  "3.3.2" "-" NETXEN_NIC_BUILD_NO
-#define NETXEN_NIC_FW_VERSIONID "3.3.2"
+#define _NETXEN_NIC_LINUX_SUBVERSION 3
+#define NETXEN_NIC_LINUX_VERSIONID  "3.3.3" "-" NETXEN_NIC_BUILD_NO
 
 #define RCV_DESC_RINGSIZE  \
(sizeof(struct rcv_desc) * adapter->max_rx_desc_count)
diff --git a/drivers/net/netxen/netxen_nic_hw.c 
b/drivers/net/netxen/netxen_nic_hw.c
index c0c31d1..191e233 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -984,7 +984,8 @@ void netxen_nic_flash_print(struct netxe
   _NETXEN_NIC_LINUX_MAJOR, fw_major);
adapter->driver_mismatch = 1;
}
-   if (fw_minor != _NETXEN_NIC_LINUX_MINOR) {
+   if (fw_minor != _NETXEN_NIC_LINUX_MINOR &&
+   fw_minor != (_NETXEN_NIC_LINUX_MINOR + 1)) {
printk(KERN_ERR "The mismatch in driver version and firmware "
   "version minor number\n"
   "Driver version minor number = %d \t"
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] NetXen: NetXen 1G/10G Ethernet Driver updates

2007-01-22 Thread Amit S. Kale
I will be sending NetXen: 1G/10G Ethernet Driver updates in subsequent emails.

Thanks,
--Amit
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] netxen: remove private ioctl

2006-12-26 Thread Amit S. Kale
On Friday 15 December 2006 21:27, Stephen Hemminger wrote:
> The netxen driver includes a private ioctl that provides access
> to functionality that is already available in other ways. The PCI
> layer has application access hooks (see setpci), and the statistics
> are available in ethtool/netstats.

Thanks.
We needed ioctls mainly for debugging a tool and for flashing. We'll soon send 
a patch to make our flash tool work through ethtool interface. Should be much 
cleaner.

-Amit

>
> Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>
> ---
>  drivers/net/netxen/netxen_nic.h |   11 -
>  drivers/net/netxen/netxen_nic_ethtool.c |5 -
>  drivers/net/netxen/netxen_nic_hw.c  |  294
> --- drivers/net/netxen/netxen_nic_init.c| 
> 237 - drivers/net/netxen/netxen_nic_ioctl.h   |  
> 77 
>  drivers/net/netxen/netxen_nic_main.c|   45 -
>  6 files changed, 1 insertions(+), 668 deletions(-)
>
> diff --git a/drivers/net/netxen/netxen_nic.h
> b/drivers/net/netxen/netxen_nic.h index b5410be..b4c4fc0 100644
> --- a/drivers/net/netxen/netxen_nic.h
> +++ b/drivers/net/netxen/netxen_nic.h
> @@ -1027,14 +1027,6 @@ int netxen_nic_hw_read_wx(struct netxen_
> int len);
>  int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void
> *data, int len);
> -int netxen_nic_hw_read_ioctl(struct netxen_adapter *adapter, u64 off,
> -  void *data, int len);
> -int netxen_nic_hw_write_ioctl(struct netxen_adapter *adapter, u64 off,
> -   void *data, int len);
> -int netxen_nic_pci_mem_write_ioctl(struct netxen_adapter *adapter,
> -u64 off, void *data, int size);
> -int netxen_nic_pci_mem_read_ioctl(struct netxen_adapter *adapter,
> -   u64 off, void *data, int size);
>  void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
>unsigned long off, int data);
>
> @@ -1067,9 +1059,6 @@ void netxen_tso_check(struct netxen_adap
> struct cmd_desc_type0 *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(struct work_struct *work);
> diff --git a/drivers/net/netxen/netxen_nic_ethtool.c
> b/drivers/net/netxen/netxen_nic_ethtool.c index 2ab4885..3404461 100644
> --- a/drivers/net/netxen/netxen_nic_ethtool.c
> +++ b/drivers/net/netxen/netxen_nic_ethtool.c
> @@ -42,7 +42,6 @@ #include 
>  #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];
> @@ -79,8 +78,7 @@ static const struct netxen_nic_stats net
>   {"tx_bytes", NETXEN_NIC_STAT(stats.txbytes)},
>  };
>
> -#define NETXEN_NIC_STATS_LEN \
> - sizeof(netxen_nic_gstrings_stats) / sizeof(struct netxen_nic_stats)
> +#define NETXEN_NIC_STATS_LEN ARRAY_SIZE(netxen_nic_gstrings_stats)
>
>  static const char netxen_nic_gstrings_test[][ETH_GSTRING_LEN] = {
>   "Register_Test_offline", "EEPROM_Test_offline",
> @@ -711,7 +709,6 @@ netxen_nic_get_ethtool_stats(struct net_
>   (netxen_nic_gstrings_stats[index].sizeof_stat ==
>sizeof(u64)) ? *(u64 *) p : *(u32 *) p;
>   }
> -
>  }
>
>  struct ethtool_ops netxen_nic_ethtool_ops = {
> diff --git a/drivers/net/netxen/netxen_nic_hw.c
> b/drivers/net/netxen/netxen_nic_hw.c index 9147b60..5dac50c 100644
> --- a/drivers/net/netxen/netxen_nic_hw.c
> +++ b/drivers/net/netxen/netxen_nic_hw.c
> @@ -997,297 +997,3 @@ void netxen_nic_flash_print(struct netxe
>  fw_major, fw_minor);
>  }
>
> -int netxen_crb_read_val(struct netxen_adapter *adapter, unsigned long off)
> -{
> - int data;
> - netxen_nic_hw_read_wx(adapter, off, &data, 4);
> - return data;
> -}
> -
> -int netxen_nic_hw_write_ioctl(struct netxen_adapter *adapter, u64 off,
> -   void *data, int len)
> -{
> - void *addr;
> - u64 offset = off;
> - u8 *mem_ptr = NULL;
> - unsigned long mem_base;
> - unsigned long mem_page;
> -
> - if (ADDR_IN_WINDOW1(off)) {
> - addr = NETXEN_CRB_NORMALIZE(adapter, off);
> - if (!addr) {
> - mem_base = pci_resource_start(adapter->ahw.pdev, 0);
> - offset = NETXEN_CRB_NORMAL(off);
> - mem_page = offset & PAGE_MASK;
> - if (mem_page != ((offset + len - 1) & PAGE_MASK))
> - mem_ptr =
> - ioremap(me

[PATCH 5/8] NetXen: Link status message correction for quad port cards.

2006-12-18 Thread Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>
 
 netxen_nic_isr.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)
  

diff --git a/drivers/net/netxen/netxen_nic_isr.c 
b/drivers/net/netxen/netxen_nic_isr.c
index 1b45f50..06847d4 100644
--- a/drivers/net/netxen/netxen_nic_isr.c
+++ b/drivers/net/netxen/netxen_nic_isr.c
@@ -157,7 +157,8 @@ void netxen_nic_isr_other(struct netxen_
for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++) {
linkup = val & 1;
if (linkup != (qg_linksup & 1)) {
-   printk(KERN_INFO "%s: PORT %d link %s\n",
+   printk(KERN_INFO "%s: %s PORT %d link %s\n",
+  adapter->port[portno]->netdev->name,
   netxen_nic_driver_name, portno,
   ((linkup == 0) ? "down" : "up"));
netxen_indicate_link_status(adapter, portno, linkup);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/8] NetXen: 1G/10G Ethernet Driver updates

2006-12-18 Thread Amit S. Kale

I will be sending NetXen: 1G/10G Ethernet Driver updates in subsequent emails.

Thanks,
--Amit
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/8] NetXen: work queue fixes.

2006-12-18 Thread Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]> 
 
 netxen_nic.h  |3 +--
 netxen_nic_init.c |2 +-
 netxen_nic_main.c |   15 +++
 3 files changed, 9 insertions(+), 11 deletions(-)


diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 421a074..86dcd52 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -852,8 +852,6 @@ struct netxen_adapter {
spinlock_t tx_lock;
spinlock_t lock;
struct work_struct watchdog_task;
-   struct work_struct tx_timeout_task;
-   struct net_device *netdev;
struct timer_list watchdog_timer;
 
u32 curr_window;
@@ -949,6 +947,7 @@ struct netxen_port {
struct pci_dev *pdev;
struct net_device_stats net_stats;
struct netxen_port_stats stats;
+   struct work_struct tx_timeout_task;
 };
 
 #define PCI_OFFSET_FIRST_RANGE(adapter, off)\
diff --git a/drivers/net/netxen/netxen_nic_init.c 
b/drivers/net/netxen/netxen_nic_init.c
index 869725f..c147943 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -1023,7 +1023,7 @@ int netxen_process_cmd_ring(unsigned lon
 && netif_carrier_ok(port->netdev))
&& ((jiffies - port->netdev->trans_start) >
port->netdev->watchdog_timeo)) {
-   SCHEDULE_WORK(&port->adapter->tx_timeout_task);
+   SCHEDULE_WORK(&port->tx_timeout_task);
}
 
last_consumer = get_next_index(last_consumer,
diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index 926ead7..bc08d21 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -424,8 +424,7 @@ netxen_nic_probe(struct pci_dev *pdev, c
 netdev->dev_addr);
}
}
-   adapter->netdev = netdev;
-   INIT_WORK(&adapter->tx_timeout_task, netxen_tx_timeout_task);
+   INIT_WORK(&port->tx_timeout_task, netxen_tx_timeout_task);
netif_carrier_off(netdev);
netif_stop_queue(netdev);
 
@@ -966,23 +965,23 @@ static void netxen_tx_timeout(struct net
 {
struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev);
 
-   SCHEDULE_WORK(&port->adapter->tx_timeout_task);
+   SCHEDULE_WORK(&port->tx_timeout_task);
 }
 
 static void netxen_tx_timeout_task(struct work_struct *work)
 {
-   struct netxen_adapter *adapter =
-   container_of(work, struct netxen_adapter, tx_timeout_task);
-   struct net_device *netdev = adapter->netdev;
+   struct netxen_port *port =
+   container_of(work, struct netxen_port, tx_timeout_task);
+   struct net_device *netdev = port->netdev;
unsigned long flags;
 
printk(KERN_ERR "%s %s: transmit timeout, resetting.\n",
   netxen_nic_driver_name, netdev->name);
 
-   spin_lock_irqsave(&adapter->lock, flags);
+   spin_lock_irqsave(&port->adapter->lock, flags);
netxen_nic_close(netdev);
netxen_nic_open(netdev);
-   spin_unlock_irqrestore(&adapter->lock, flags);
+   spin_unlock_irqrestore(&port->adapter->lock, flags);
netdev->trans_start = jiffies;
netif_wake_queue(netdev);
 }
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/8] NetXen: Multiple adapter fix.

2006-12-18 Thread Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

 netxen_nic.h  |3 +--
 netxen_nic_main.c |   12 
 2 files changed, 1 insertion(+), 14 deletions(-)


diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index b5410be..421a074 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -63,7 +63,7 @@
 
 #include "netxen_nic_hw.h"
 
-#define NETXEN_NIC_BUILD_NO "1"
+#define NETXEN_NIC_BUILD_NO "2"
 #define _NETXEN_NIC_LINUX_MAJOR 3
 #define _NETXEN_NIC_LINUX_MINOR 3
 #define _NETXEN_NIC_LINUX_SUBVERSION 2
@@ -887,7 +887,6 @@ struct netxen_adapter {
struct netxen_recv_context recv_ctx[MAX_RCV_CTX];
 
int is_up;
-   int number;
struct netxen_dummy_dma dummy_dma;
 
/* Context interface shared between card and host */
diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index f2b3fbc..926ead7 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -53,8 +53,6 @@ char netxen_nic_driver_name[] = "netxen-
 static char netxen_nic_driver_string[] = "NetXen Network Driver version "
 NETXEN_NIC_LINUX_VERSIONID;
 
-struct netxen_adapter *g_adapter = NULL;
-
 #define NETXEN_NETDEV_WEIGHT 120
 #define NETXEN_ADAPTER_UP_MAGIC 777
 #define NETXEN_NIC_PEG_TUNE 0
@@ -131,7 +129,6 @@ netxen_nic_probe(struct pci_dev *pdev, c
struct netxen_cmd_buffer *cmd_buf_arr = NULL;
u64 mac_addr[FLASH_NUM_PORTS + 1];
int valid_mac = 0;
-   static int netxen_cards_found = 0;
 
printk(KERN_INFO "%s \n", netxen_nic_driver_string);
/* In current scheme, we use only PCI function 0 */
@@ -222,9 +219,6 @@ netxen_nic_probe(struct pci_dev *pdev, c
goto err_out_dbunmap;
}
 
-   if (netxen_cards_found == 0) {
-   g_adapter = adapter;
-   }
adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS;
adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS;
adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS;
@@ -468,7 +462,6 @@ netxen_nic_probe(struct pci_dev *pdev, c
break;
}
 
-   adapter->number = netxen_cards_found;
adapter->driver_mismatch = 0;
 
return 0;
@@ -965,11 +958,6 @@ static int netxen_nic_xmit_frame(struct
 static void netxen_watchdog(unsigned long v)
 {
struct netxen_adapter *adapter = (struct netxen_adapter *)v;
-   if (adapter != g_adapter) {
-   printk("%s: ***BUG*** adapter[%p] != g_adapter[%p]\n",
-  __FUNCTION__, adapter, g_adapter);
-   return;
-   }
 
SCHEDULE_WORK(&adapter->watchdog_task);
 }
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/8] NetXen: Adding new device ids.

2006-12-18 Thread Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

netxen_nic_main.c |2 ++
 1 files changed, 2 insertions(+)


diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index 575b71b..d8b1daf 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -90,6 +90,8 @@ static struct pci_device_id netxen_pci_t
{PCI_DEVICE(0x4040, 0x0003)},
{PCI_DEVICE(0x4040, 0x0004)},
{PCI_DEVICE(0x4040, 0x0005)},
+   {PCI_DEVICE(0x4040, 0x0024)},
+   {PCI_DEVICE(0x4040, 0x0025)},
{0,}
 };
 
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 8/8] NetXen: Reducing ring sizes for IOMMU issue.

2006-12-18 Thread Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]> 
 
 netxen_nic.h |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)
  

diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index fe9bff0..32032b0 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -63,7 +63,7 @@
 
 #include "netxen_nic_hw.h"
 
-#define NETXEN_NIC_BUILD_NO "3"
+#define NETXEN_NIC_BUILD_NO "4"
 #define _NETXEN_NIC_LINUX_MAJOR 3
 #define _NETXEN_NIC_LINUX_MINOR 3
 #define _NETXEN_NIC_LINUX_SUBVERSION 2
@@ -137,7 +137,7 @@ extern struct workqueue_struct *netxen_w
 #define THIRD_PAGE_GROUP_SIZE  THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START
 
 #define MAX_RX_BUFFER_LENGTH   1760
-#define MAX_RX_JUMBO_BUFFER_LENGTH 9046
+#define MAX_RX_JUMBO_BUFFER_LENGTH 8062
 #define MAX_RX_LRO_BUFFER_LENGTH   ((48*1024)-512)
 #define RX_DMA_MAP_LEN (MAX_RX_BUFFER_LENGTH - 2)
 #define RX_JUMBO_DMA_MAP_LEN   \
@@ -199,9 +199,9 @@ enum {
(RCV_DESC_NORMAL)))
 
 #define MAX_CMD_DESCRIPTORS1024
-#define MAX_RCV_DESCRIPTORS32768
-#define MAX_JUMBO_RCV_DESCRIPTORS  4096
-#define MAX_LRO_RCV_DESCRIPTORS2048
+#define MAX_RCV_DESCRIPTORS16384
+#define MAX_JUMBO_RCV_DESCRIPTORS  1024
+#define MAX_LRO_RCV_DESCRIPTORS64
 #define MAX_RCVSTATUS_DESCRIPTORS  MAX_RCV_DESCRIPTORS
 #define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS
 #define MAX_RCV_DESC   MAX_RCV_DESCRIPTORS
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/8] NetXen: Using correct CHECKSUM flag.

2006-12-18 Thread Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

netxen_nic_hw.c |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


diff --git a/drivers/net/netxen/netxen_nic_hw.c 
b/drivers/net/netxen/netxen_nic_hw.c
index 9147b60..f2850bf 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -376,7 +376,7 @@ void netxen_tso_check(struct netxen_adap
((skb->nh.iph)->ihl * sizeof(u32)) +
((skb->h.th)->doff * sizeof(u32));
netxen_set_cmd_desc_opcode(desc, TX_TCP_LSO);
-   } else if (skb->ip_summed == CHECKSUM_COMPLETE) {
+   } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
if (skb->nh.iph->protocol == IPPROTO_TCP) {
netxen_set_cmd_desc_opcode(desc, TX_TCP_PKT);
} else if (skb->nh.iph->protocol == IPPROTO_UDP) {
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/8] NetXen: Fix for PPC machines.

2006-12-18 Thread Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]> 
 
 netxen_nic.h  |2 +-
 netxen_nic_init.c |   12 ++--
 netxen_nic_main.c |4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)


diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 86dcd52..31b2553 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -63,7 +63,7 @@
 
 #include "netxen_nic_hw.h"
 
-#define NETXEN_NIC_BUILD_NO "2"
+#define NETXEN_NIC_BUILD_NO "3"
 #define _NETXEN_NIC_LINUX_MAJOR 3
 #define _NETXEN_NIC_LINUX_MINOR 3
 #define _NETXEN_NIC_LINUX_SUBVERSION 2
diff --git a/drivers/net/netxen/netxen_nic_init.c 
b/drivers/net/netxen/netxen_nic_init.c
index c147943..c0cbc30 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -928,7 +928,7 @@ u32 netxen_process_rcv_ring(struct netxe
}
netxen_process_rcv(adapter, ctxid, desc);
netxen_clear_sts_owner(desc);
-   netxen_set_sts_owner(desc, STATUS_OWNER_PHANTOM);
+   netxen_set_sts_owner(desc, cpu_to_le16(STATUS_OWNER_PHANTOM));
consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1);
count++;
}
@@ -1138,13 +1138,13 @@ void netxen_post_rx_buffers(struct netxe
 */
dma = pci_map_single(pdev, skb->data, rcv_desc->dma_size,
 PCI_DMA_FROMDEVICE);
-   pdesc->addr_buffer = dma;
+   pdesc->addr_buffer = cpu_to_le64(dma);
buffer->skb = skb;
buffer->state = NETXEN_BUFFER_BUSY;
buffer->dma = dma;
/* make a rcv descriptor  */
-   pdesc->reference_handle = buffer->ref_handle;
-   pdesc->buffer_length = rcv_desc->dma_size;
+   pdesc->reference_handle = cpu_to_le16(buffer->ref_handle);
+   pdesc->buffer_length = cpu_to_le32(rcv_desc->dma_size);
DPRINTK(INFO, "done writing descripter\n");
producer =
get_next_index(producer, rcv_desc->max_rx_desc_count);
@@ -1232,8 +1232,8 @@ void netxen_post_rx_buffers_nodb(struct
 PCI_DMA_FROMDEVICE);
 
/* make a rcv descriptor  */
-   pdesc->reference_handle = le16_to_cpu(buffer->ref_handle);
-   pdesc->buffer_length = le16_to_cpu(rcv_desc->dma_size);
+   pdesc->reference_handle = cpu_to_le16(buffer->ref_handle);
+   pdesc->buffer_length = cpu_to_le16(rcv_desc->dma_size);
pdesc->addr_buffer = cpu_to_le64(buffer->dma);
DPRINTK(INFO, "done writing descripter\n");
producer =
diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index bc08d21..aecc07d 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -822,8 +822,8 @@ static int netxen_nic_xmit_frame(struct
/* Take skb->data itself */
pbuf = &adapter->cmd_buf_arr[producer];
if ((netdev->features & NETIF_F_TSO) && skb_shinfo(skb)->gso_size > 0) {
-   pbuf->mss = skb_shinfo(skb)->gso_size;
-   hwdesc->mss = skb_shinfo(skb)->gso_size;
+   pbuf->mss = cpu_to_le16(skb_shinfo(skb)->gso_size);
+   hwdesc->mss = cpu_to_le16(skb_shinfo(skb)->gso_size);
} else {
pbuf->mss = 0;
hwdesc->mss = 0;
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/8] NetXen: driver reload fix for newer firmware.

2006-12-18 Thread Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

netxen_nic_main.c |7 +++
 1 files changed, 7 insertions(+)


diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index d8b1daf..f2b3fbc 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -446,6 +446,11 @@ netxen_nic_probe(struct pci_dev *pdev, c
adapter->port[i] = port;
}
 
+   writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
+   netxen_pinit_from_rom(adapter, 0);
+   udelay(500);
+   netxen_load_firmware(adapter);
+   netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
/*
 * delay a while to ensure that the Pegs are up & running.
 * Otherwise, we might see some flaky behaviour.
@@ -533,6 +538,8 @@ static void __devexit netxen_nic_remove(
 
netxen_nic_stop_all_ports(adapter);
/* leave the hw in the same state as reboot */
+   netxen_pinit_from_rom(adapter, 0);
+   writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
netxen_load_firmware(adapter);
netxen_free_adapter_offload(adapter);
 
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: network devices don't handle pci_dma_mapping_error()'s

2006-12-06 Thread Amit S. Kale
On Thursday 07 December 2006 12:16, Stephen Hemminger wrote:
> Amit S. Kale wrote:
> > We can let a driver handle dma mapping errors using these->
> >
> > 1.Reduce the size of a receive ring. This will free some possibly
> > remapped memory, reducing pressure on iommu. We also need to printk a
> > message so that a user knows the reason why receive ring was shrunk.
> > Growing it when iommu pressure goes down will result in a ping-pong.
> > 2. Force processing of receive and transmit ring. This will ensure that
> > the buffers processed by hardware are freed, reducing iommu pressure.
> >
> > 3. If we need to do (1) and (2) a predefined number of times (say 20),
> > stop the queue. Stopping the queue in general will cause a ping-pong, so
> > it should be avoided as far as possible.
>
> But what if it isn't the network device that is using all the IOMMU
> resources.
> Linux is already crap at handling out of memory, lets not add another
> starvation
> path.
>
> In this case, the device does have some idea about "worst case" i/o's in
> flight,
> couldn't we have some sort of reservation/management system to avoid
> overcommitting?
> Worst case map usage for a network device can be fairly high because of
> the possiblity
> of on transmit with a high number of pages when using TSO. Perhaps the
> transmit
> ring needs to be accounted for in maps used rather than packets pending.

I am afraid I don't have a good answer for that. Any kind of reservation may 
result in underutilization and transparently shared resources may result in 
starvation.

Designing heuristics for handling these cases may be the only possible wayout, 
though these heuristics need to be validated frequently to ensure that they 
aren't out of date.
-Amit
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: network devices don't handle pci_dma_mapping_error()'s

2006-12-06 Thread Amit S. Kale
We can let a driver handle dma mapping errors using these->

1.Reduce the size of a receive ring. This will free some possibly remapped 
memory, reducing pressure on iommu. We also need to printk a message so that 
a user knows the reason why receive ring was shrunk. Growing it when iommu 
pressure goes down will result in a ping-pong.
2. Force processing of receive and transmit ring. This will ensure that the 
buffers processed by hardware are freed, reducing iommu pressure.

3. If we need to do (1) and (2) a predefined number of times (say 20), stop 
the queue. Stopping the queue in general will cause a ping-pong, so it should 
be avoided as far as possible.

-Amit


On Thursday 07 December 2006 06:28, Stephen Hemminger wrote:
> The more robust way would be to stop the queue (like flow control)
> and return busy. You would need a timer though to handle the case
> where some disk i/o stole all the mappings and then network device flow
> blocked.
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: network devices don't handle pci_dma_mapping_error()'s

2006-12-06 Thread Amit S. Kale
On Thursday 07 December 2006 01:03, Muli Ben-Yehuda wrote:
> On Wed, Dec 06, 2006 at 10:16:44AM -0800, Stephen Hemminger wrote:
> > I think it is really only an issue for drivers that turn on HIGH_DMA
> > and have limited mask values. The majority of drivers either only
> > handle 32 bit (!HIGH_DMA) or do full 64 bit mapping. I don't know
> > the details of how we manage IOMMU, but doesn't mapping always work
> > for those drivers.
>
> It's up to an IOMMU (DMA-API) implementation to define what
> constitutes a mapping error, e.g., Calgary and GART on x86-64 will
> return bad_dma_address from the mapping functions when they run out of
> entries in the IO space, which can happen regardless of the mask.

We've seen IOMMU space running out on ia64 systems. Would this be the case 
with other 10G driver requiring IOMMU remapping? We need frequent map-unmap 
at near 10G throughput.

On the x86_64 boxes that don't feature iommu functionality (because the 
motherboard disables it or because Linux can't handle it) Linux bounce buffer 
framework automatically comes into picture. Could we have the same framework 
take over when IOMMU space is over? I don't think this is possible with 
present code, though. We probably can have fallback_dma_ops in addition to 
dma_ops.

-Amit
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] netxen: sparse warning and ioctl bug fixes

2006-12-06 Thread Amit S. Kale
Hi Stephen,

This patch looks good. 

ioctls: NetXen chip is far more generic and will eventually show a significant 
amount of functionality in different products. We need ioctl analysis for 
user level tools that can tell states of registers etc. Removing ioctls all 
together will make any analysis from userland extremely difficult.

Does anyone have ideas on improving this ioctl interface?

Thanks.
-Amit

On Wednesday 06 December 2006 01:37, Stephen Hemminger wrote:
> Fix sparse warnings and get rid of casts that hide misuse
> of __user pointers.  There were two real bugs here:
>   * ioctl was copying uninitialized stack om NETXEN_NIC_NAME
>   * ioctl was dereferencing a user pointer
> in nettxen_nic_cmd_clear_stats.
>
> IMHO the ioctl usage in this driver is going to be more maintenance
> burden than useful. and should be removed.
>
> Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>
> ---
>  drivers/net/netxen/netxen_nic.h   |5 +
>  drivers/net/netxen/netxen_nic_hdr.h   |  128
> + drivers/net/netxen/netxen_nic_init.c  |  
> 38 +-
>  drivers/net/netxen/netxen_nic_ioctl.h |2 -
>  drivers/net/netxen/netxen_nic_main.c  |   34 +++--
>  5 files changed, 99 insertions(+), 108 deletions(-)
>
> diff --git a/drivers/net/netxen/netxen_nic.h
> b/drivers/net/netxen/netxen_nic.h index d925053..f66ebe3 100644
> --- a/drivers/net/netxen/netxen_nic.h
> +++ b/drivers/net/netxen/netxen_nic.h
> @@ -916,9 +916,8 @@ void netxen_tso_check(struct netxen_adap
> struct cmd_desc_type0 *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_do_ioctl(struct netxen_adapter *adapter, void __user
> *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);
> diff --git a/drivers/net/netxen/netxen_nic_hdr.h
> b/drivers/net/netxen/netxen_nic_hdr.h index 72c6ec4..2461afc 100644
> --- a/drivers/net/netxen/netxen_nic_hdr.h
> +++ b/drivers/net/netxen/netxen_nic_hdr.h
> @@ -228,139 +228,139 @@ enum {
>  /*  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)
> + (((u32)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)
> + (((u32)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)
> + (((u32)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)
> + (((u32)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)
> + (((u32)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)
> + (((u32)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)
> + (((u32)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)
> + (((u32)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)
> + (((u32)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)
> + (((u32)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)
> + (((u32)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)
> + (((u32)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)
> + (((u32)NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_C2C1_CRB_AGT_ADR)
>  #define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX2  \
> -

[PATCH 1/2] NetXen: whitespace cleaup and more cleanup fixes

2006-12-04 Thread Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

 netxen_nic.h |   56 --
 netxen_nic_ethtool.c |   53 +---
 netxen_nic_hdr.h |6 ++---
 netxen_nic_hw.c  |   54 +
 netxen_nic_hw.h  |   10 
 netxen_nic_init.c|   61 +--
 netxen_nic_ioctl.h   |6 ++---
 netxen_nic_isr.c |   48 +---
 netxen_nic_main.c|   54 +
 netxen_nic_niu.c |   10 
 10 files changed, 165 insertions(+), 193 deletions(-)


diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index d925053..d51f437 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -1,25 +1,25 @@
 /*
  * 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:
  *[EMAIL PROTECTED]
  * NetXen,
@@ -89,8 +89,8 @@
  * normalize a 64MB crb address to 32MB PCI window 
  * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1
  */
-#define NETXEN_CRB_NORMAL(reg)\
-   (reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST
+#define NETXEN_CRB_NORMAL(reg) \
+   ((reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)
 
 #define NETXEN_CRB_NORMALIZE(adapter, reg) \
pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg))
@@ -164,7 +164,7 @@ enum {
 
 #define MAX_CMD_DESCRIPTORS1024
 #define MAX_RCV_DESCRIPTORS32768
-#define MAX_JUMBO_RCV_DESCRIPTORS  1024
+#define MAX_JUMBO_RCV_DESCRIPTORS  4096
 #define MAX_RCVSTATUS_DESCRIPTORS  MAX_RCV_DESCRIPTORS
 #define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS
 #define MAX_RCV_DESC   MAX_RCV_DESCRIPTORS
@@ -559,7 +559,7 @@ typedef enum {
 #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_USER_SIZE(sizeof(struct 
netxen_user_info)/sizeof(u32))
 #define FLASH_SECONDARY_SIZE   (USER_START-SECONDARY_START)
 #define NUM_PRIMARY_SECTORS(0x20)
 #define NUM_CONFIG_SECTORS (1)
@@ -572,7 +572,7 @@ typedef enum {
 #else
 #define DPRINTK(klevel, fmt, args...)  do { \
printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\
-   (adapter != NULL && adapter->port != NULL && \
+   (adapter != NULL && \
adapter->port[0] != NULL && \
adapter->port[0]->netdev != NULL) ? \
adapter->port[0]->netdev->name : NULL, \
@@ -703,8 +703,6 @@ struct netxen_recv_context {
 
 #define NETXEN_NIC_MSI_ENABLED 0x02
 
-struct netxen_drvops;
-
 struct netxen_adapter {
struct netxen_hardware_context ahw;
int port_count; /* Number of configured ports  */
@@ -746,8 +744,21 @@ struct netxen_adapter {
struct netxen_recv_context recv_ctx[MAX_RCV_CTX];
 
int is_up;
-   int work_done;
-   struct netxen_drvops *ops;
+   int (*enable_phy_interrupts) (struct netxen_adapter *, int);
+   int (*disable_phy_interrupts) (struct netxen_adapter *, int);
+   void (*handle_phy_intr) (struct netxen_adapter *);
+   int (*macaddr_set) (struct netxen_port *, netxen_ethernet_macaddr_t);
+   int (*set_mtu) (struct netxen_port *, int);
+   int (*set_promisc) (struct netxen_adapter *, int,
+   netxen_niu_prom_mode_t);
+   int (*unset_promisc) (struct netxen_adapter *, int,
+ netxen_niu_prom_mode_t);
+   int (*phy_read) (struct netxen_adapter *, long phy, long reg, u32 *);
+   int (*phy_write) (struct netxen_adapter *, long phy, long reg, u32 val);
+   int (*init_port) (struct netxen_adapter *, int);
+   void (*init_niu) (stru

[PATCH 0/2] NetXen: 1G/10G Ethernet Driver updates

2006-12-04 Thread Amit S. Kale
Hi All,

We have incorporated feedbacks received during last post. We have removed 
bounce buffer as well.
I will be sending patches shortly. These patches are wrt netdev#master.

Thanks,
--Amit
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] NetXen: 64-bit memory fixes

2006-12-01 Thread Amit S. Kale
NetXen: 1G/10G Ethernet driver updates
- These fixes take care of driver on machines with >4G memory
- Driver cleanup

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

 netxen_nic.h  |   29 +--
 netxen_nic_ethtool.c  |   19 ++--
 netxen_nic_hw.c   |4 
 netxen_nic_hw.h   |4 
 netxen_nic_init.c |   51 +++-
 netxen_nic_isr.c  |3 
 netxen_nic_main.c |  204 +++---
 netxen_nic_phan_reg.h |   10 +-
 8 files changed, 286 insertions(+), 38 deletions(-)


diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index d925053..029e6c7 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -6,12 +6,12 @@
  * 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,
@@ -89,8 +89,8 @@
  * normalize a 64MB crb address to 32MB PCI window 
  * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1
  */
-#define NETXEN_CRB_NORMAL(reg)\
-   (reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST
+#define NETXEN_CRB_NORMAL(reg) \
+   ((reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)
 
 #define NETXEN_CRB_NORMALIZE(adapter, reg) \
pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg))
@@ -164,7 +164,7 @@ enum {
 
 #define MAX_CMD_DESCRIPTORS1024
 #define MAX_RCV_DESCRIPTORS32768
-#define MAX_JUMBO_RCV_DESCRIPTORS  1024
+#define MAX_JUMBO_RCV_DESCRIPTORS  4096
 #define MAX_RCVSTATUS_DESCRIPTORS  MAX_RCV_DESCRIPTORS
 #define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS
 #define MAX_RCV_DESC   MAX_RCV_DESCRIPTORS
@@ -591,6 +591,16 @@ struct netxen_skb_frag {
u32 length;
 };
 
+/* Bounce buffer index */
+struct bounce_index {
+   /* Index of a buffer */
+   unsigned buffer_index;
+   /* Offset inside the buffer */
+   unsigned buffer_offset;
+};
+
+#define IS_BOUNCE 0xcafebb
+
 /*Following defines are for the state of the buffers*/
 #defineNETXEN_BUFFER_FREE  0
 #defineNETXEN_BUFFER_BUSY  1
@@ -610,6 +620,8 @@ struct netxen_cmd_buffer {
unsigned long time_stamp;
u32 state;
u32 no_of_descriptors;
+   u32 tx_bounce_buff;
+   struct bounce_index bnext;
 };
 
 /* In rx_buffer, we do not need multiple fragments as is a single buffer */
@@ -618,6 +630,9 @@ struct netxen_rx_buffer {
u64 dma;
u16 ref_handle;
u16 state;
+   u32 rx_bounce_buff;
+   struct bounce_index bnext;
+   char *bounce_ptr;
 };
 
 /* Board types */
@@ -702,6 +717,7 @@ struct netxen_recv_context {
 };
 
 #define NETXEN_NIC_MSI_ENABLED 0x02
+#define NETXEN_DMA_MASK0xfffe
 
 struct netxen_drvops;
 
@@ -1018,6 +1034,9 @@ static inline void get_brd_name_by_type(
 
 int netxen_is_flash_supported(struct netxen_adapter *adapter);
 int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]);
+int netxen_get_next_bounce_buffer(struct bounce_index *head,
+ struct bounce_index *tail,
+ struct bounce_index *biret, unsigned len);
 
 extern void netxen_change_ringparam(struct netxen_adapter *adapter);
 extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr,
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c 
b/drivers/net/netxen/netxen_nic_ethtool.c
index 9a914ae..8d8e5e1 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -6,12 +6,12 @@
  * 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,
@@ -118,7 +118,7 @@ netxen_nic_get_drvinfo(struct net_device
u32 fw_minor = 0;
  

[PATCH 1/3] NetXen: driver cleanup, removed unnecessary __iomem type casts

2006-12-01 Thread Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

 netxen_nic.h |   38 --
 netxen_nic_ethtool.c |5 ++---
 netxen_nic_hw.c  |   12 +---
 netxen_nic_main.c|8 +++-
 4 files changed, 18 insertions(+), 45 deletions(-)


diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 1bee560..d925053 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -343,7 +343,6 @@ typedef enum {
NETXEN_BRDTYPE_P2_SB31_10G_HMEZ = 0x000e,
NETXEN_BRDTYPE_P2_SB31_10G_CX4 = 0x000f
 } netxen_brdtype_t;
-#define NUM_SUPPORTED_BOARDS (sizeof(netxen_boards)/sizeof(netxen_brdinfo_t))
 
 typedef enum {
NETXEN_BRDMFG_INVENTEC = 1
@@ -937,9 +936,7 @@ static inline void netxen_nic_disable_in
/*
 * ISR_INT_MASK: Can be read from window 0 or 1.
 */
-   writel(0x7ff,
-  (void __iomem
-   *)(PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK)));
+   writel(0x7ff, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
 
 }
 
@@ -959,14 +956,12 @@ static inline void netxen_nic_enable_int
break;
}
 
-   writel(mask,
-  (void __iomem
-   *)(PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK)));
+   writel(mask, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
 
if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
mask = 0xbff;
-   writel(mask, (void __iomem *)
-  (PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_TARGET_MASK)));
+   writel(mask, PCI_OFFSET_SECOND_RANGE(adapter,
+ISR_INT_TARGET_MASK));
}
 }
 
@@ -975,13 +970,13 @@ static inline void netxen_nic_enable_int
  */
 
 #define NETXEN_MAX_SHORT_NAME 16
-typedef struct {
+struct netxen_brdinfo {
netxen_brdtype_t brdtype;   /* type of board */
long ports; /* max no of physical ports */
char short_name[NETXEN_MAX_SHORT_NAME];
-} netxen_brdinfo_t;
+};
 
-static const netxen_brdinfo_t netxen_boards[] = {
+static const struct netxen_brdinfo netxen_boards[] = {
{NETXEN_BRDTYPE_P2_SB31_10G_CX4, 1, "XGb CX4"},
{NETXEN_BRDTYPE_P2_SB31_10G_HMEZ, 1, "XGb HMEZ"},
{NETXEN_BRDTYPE_P2_SB31_10G_IMEZ, 2, "XGb IMEZ"},
@@ -990,24 +985,7 @@ static const netxen_brdinfo_t netxen_boa
{NETXEN_BRDTYPE_P2_SB31_2G, 2, "Dual Gb"},
 };
 
-#define NUM_SUPPORTED_BOARDS (sizeof(netxen_boards)/sizeof(netxen_brdinfo_t))
-
-static inline void get_brd_ports_name_by_type(u32 type, int *ports, char *name)
-{
-   int i, found = 0;
-   for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) {
-   if (netxen_boards[i].brdtype == type) {
-   *ports = netxen_boards[i].ports;
-   strcpy(name, netxen_boards[i].short_name);
-   found = 1;
-   break;
-   }
-   }
-   if (!found) {
-   *ports = 0;
-   name = "Unknown";
-   }
-}
+#define NUM_SUPPORTED_BOARDS (sizeof(netxen_boards)/sizeof(struct 
netxen_brdinfo))
 
 static inline void get_brd_port_by_type(u32 type, int *ports)
 {
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c 
b/drivers/net/netxen/netxen_nic_ethtool.c
index f3fc35c..9a914ae 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -139,8 +139,7 @@ netxen_nic_get_settings(struct net_devic
 {
struct netxen_port *port = netdev_priv(dev);
struct netxen_adapter *adapter = port->adapter;
-   struct netxen_board_info *boardinfo;
-   boardinfo = &adapter->ahw.boardcfg;
+   struct netxen_board_info *boardinfo = &adapter->ahw.boardcfg;
 
/* read which mode */
if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
@@ -208,7 +207,7 @@ netxen_nic_get_settings(struct net_devic
ecmd->autoneg = AUTONEG_DISABLE;
break;
default:
-   printk("ERROR: Unsupported board model %d\n",
+   printk(KERN_ERR "netxen-nic: Unsupported board model %d\n",
   (netxen_brdtype_t) boardinfo->board_type);
return -EIO;
 
diff --git a/drivers/net/netxen/netxen_nic_hw.c 
b/drivers/net/netxen/netxen_nic_hw.c
index 99e647a..105c24f 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -275,10 +275,8 @@ int netxen_nic_hw_resources(struct netxe
rcv_desc->desc_head = (struct rcv_desc *)addr;
}
 
-   addr = netxen_alloc(adapter->ahw.pdev,
-   STATUS_DESC_RINGSIZE,
-   &recv_ctx->
-   rcv_status_desc_phys_add

[PATCH 0/3] NetXen: 1G/10G Ethernet Driver updates

2006-12-01 Thread Amit S. Kale
Hi,

Thanks Ueimor, Stephen, and Jeff!
We have incorporated all your feedbacks, and rebased wrt 
5e3f6b98b639c611c45751081c59ae9a04081964.
I will be sending patchset shortly.

--Amit
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] NetXen: 64-bit memory fixes and driver cleanup

2006-11-29 Thread Amit S. Kale
NetXen: 1G/10G Ethernet Driver updates
- These fixes take care of driver on machines with >4G memory
- Driver cleanup

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

 netxen_nic.h  |   41 ++
 netxen_nic_ethtool.c  |   19 ++--
 netxen_nic_hw.c   |   10 +-
 netxen_nic_hw.h   |4 
 netxen_nic_init.c |   51 +++-
 netxen_nic_isr.c  |3 
 netxen_nic_main.c |  204 +++---
 netxen_nic_phan_reg.h |   10 +-
 8 files changed, 293 insertions(+), 49 deletions(-)


diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 1bee560..84259f9 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -6,12 +6,12 @@
  * 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,
@@ -89,8 +89,8 @@
  * normalize a 64MB crb address to 32MB PCI window 
  * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1
  */
-#define NETXEN_CRB_NORMAL(reg)\
-   (reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST
+#define NETXEN_CRB_NORMAL(reg) \
+   ((reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)
 
 #define NETXEN_CRB_NORMALIZE(adapter, reg) \
pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg))
@@ -164,7 +164,7 @@ enum {
 
 #define MAX_CMD_DESCRIPTORS1024
 #define MAX_RCV_DESCRIPTORS32768
-#define MAX_JUMBO_RCV_DESCRIPTORS  1024
+#define MAX_JUMBO_RCV_DESCRIPTORS  4096
 #define MAX_RCVSTATUS_DESCRIPTORS  MAX_RCV_DESCRIPTORS
 #define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS
 #define MAX_RCV_DESC   MAX_RCV_DESCRIPTORS
@@ -592,6 +592,16 @@ struct netxen_skb_frag {
u32 length;
 };
 
+/* Bounce buffer index */
+struct bounce_index {
+   /* Index of a buffer */
+   unsigned buffer_index;
+   /* Offset inside the buffer */
+   unsigned buffer_offset;
+};
+
+#define IS_BOUNCE 0xcafebb
+
 /*Following defines are for the state of the buffers*/
 #defineNETXEN_BUFFER_FREE  0
 #defineNETXEN_BUFFER_BUSY  1
@@ -611,6 +621,8 @@ struct netxen_cmd_buffer {
unsigned long time_stamp;
u32 state;
u32 no_of_descriptors;
+   u32 tx_bounce_buff;
+   struct bounce_index bnext;
 };
 
 /* In rx_buffer, we do not need multiple fragments as is a single buffer */
@@ -619,6 +631,9 @@ struct netxen_rx_buffer {
u64 dma;
u16 ref_handle;
u16 state;
+   u32 rx_bounce_buff;
+   struct bounce_index bnext;
+   char *bounce_ptr;
 };
 
 /* Board types */
@@ -703,6 +718,7 @@ struct netxen_recv_context {
 };
 
 #define NETXEN_NIC_MSI_ENABLED 0x02
+#define NETXEN_DMA_MASK0xfffe
 
 struct netxen_drvops;
 
@@ -937,9 +953,7 @@ static inline void netxen_nic_disable_in
/*
 * ISR_INT_MASK: Can be read from window 0 or 1.
 */
-   writel(0x7ff,
-  (void __iomem
-   *)(PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK)));
+   writel(0x7ff, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
 
 }
 
@@ -959,14 +973,12 @@ static inline void netxen_nic_enable_int
break;
}
 
-   writel(mask,
-  (void __iomem
-   *)(PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK)));
+   writel(mask, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
 
if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
mask = 0xbff;
-   writel(mask, (void __iomem *)
-  (PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_TARGET_MASK)));
+   writel(mask, PCI_OFFSET_SECOND_RANGE(adapter,
+ISR_INT_TARGET_MASK));
}
 }
 
@@ -1040,6 +1052,9 @@ static inline void get_brd_name_by_type(
 
 int netxen_is_flash_supported(struct netxen_adapter *adapter);
 int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]);
+int netxen_get_next_bounce_buffer(struct bounce_index *head,
+ struct bounce_index *tail,
+ struct bounce_index *biret, unsigned len);
 
 extern void netxen_change_ringparam(struct netxen_adapter *adapter);
 extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr,
diff --git a/dr

[PATCH 1/4] NetXen: Fixed /sys mapping between device and driver

2006-11-29 Thread Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

 netxen_nic_main.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)


diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index 145bf47..a055208 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -273,6 +273,7 @@ netxen_nic_probe(struct pci_dev *pdev, c
}
 
SET_MODULE_OWNER(netdev);
+   SET_NETDEV_DEV(netdev, &pdev->dev);
 
port = netdev_priv(netdev);
port->netdev = netdev;
@@ -1043,7 +1044,7 @@ static int netxen_nic_poll(struct net_de
netxen_nic_enable_int(adapter);
}
 
-   return (done ? 0 : 1);
+   return !done;
 }
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/4] NetXen: 1G/10G Ethernet Driver updates

2006-11-29 Thread Amit S. Kale

I will be sending NetXen: 1G/10G Ethernet Driver updates in subsequent emails.

Thanks,
--Amit
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: Re: [PATCH 3/3] NetXen: 64-bit memory fixes, driver cleanup

2006-11-28 Thread Amit S. Kale

Hi Stephen,


> > you need explicit bounce buffers.  If you can't DMA from unaligned 

address,

> > > the write a small routine to copy the skb to a new one.
> >
> >
> > The hardware supports DMA into 35 bit addresses. The intent is to
> > enable DMA into addresses upto 32G.
> >
>
> You should then set the same value for pci_set_dma_mask, because then 

the IOMMU
> can help. See both b44 or tg3 drivers, they have to deal with odd size 

masks.

> I don't think you have to do all the bounce buffer work in the driver.


Using bounce buffers has following tradeoffs:
1. Overhead of code maintenance.
2. Slow performance.
Also on some ia64 machines we saw reduced performance because of larger 
ring sizes.


But if we remove bounce buffers and use IOMMU instead, it might not 
work for some Opteron configurations. On one of our Opterons we could not 
set the IOMMU from kernel command line (it asked to set it from the BIOS where there was no 
such option in the BIOS)


So what do you suggest, should we use the IOMMU or should we keep the 
bounce buffers as they are?


Thanks,
Amit Kale.


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


[PATCH 3/3] NetXen: 64-bit memory fixes, driver cleanup

2006-11-17 Thread Linsys Contractor Amit S. Kale
NetXen: 1G/10G Ethernet Driver updates
- These fixes take care of driver on machines with >4G memory
- Driver cleanup

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

 netxen_nic.h  |   41 ++
 netxen_nic_ethtool.c  |   19 ++--
 netxen_nic_hw.c   |   10 +-
 netxen_nic_hw.h   |4 
 netxen_nic_init.c |   51 +++-
 netxen_nic_isr.c  |3 
 netxen_nic_main.c |  204 +++---
 netxen_nic_phan_reg.h |   10 +-
 8 files changed, 293 insertions(+), 49 deletions(-)


diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 1bee560..84259f9 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -6,12 +6,12 @@
  * 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,
@@ -89,8 +89,8 @@
  * normalize a 64MB crb address to 32MB PCI window 
  * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1
  */
-#define NETXEN_CRB_NORMAL(reg)\
-   (reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST
+#define NETXEN_CRB_NORMAL(reg) \
+   ((reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)
 
 #define NETXEN_CRB_NORMALIZE(adapter, reg) \
pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg))
@@ -164,7 +164,7 @@ enum {
 
 #define MAX_CMD_DESCRIPTORS1024
 #define MAX_RCV_DESCRIPTORS32768
-#define MAX_JUMBO_RCV_DESCRIPTORS  1024
+#define MAX_JUMBO_RCV_DESCRIPTORS  4096
 #define MAX_RCVSTATUS_DESCRIPTORS  MAX_RCV_DESCRIPTORS
 #define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS
 #define MAX_RCV_DESC   MAX_RCV_DESCRIPTORS
@@ -592,6 +592,16 @@ struct netxen_skb_frag {
u32 length;
 };
 
+/* Bounce buffer index */
+struct bounce_index {
+   /* Index of a buffer */
+   unsigned buffer_index;
+   /* Offset inside the buffer */
+   unsigned buffer_offset;
+};
+
+#define IS_BOUNCE 0xcafebb
+
 /*Following defines are for the state of the buffers*/
 #defineNETXEN_BUFFER_FREE  0
 #defineNETXEN_BUFFER_BUSY  1
@@ -611,6 +621,8 @@ struct netxen_cmd_buffer {
unsigned long time_stamp;
u32 state;
u32 no_of_descriptors;
+   u32 tx_bounce_buff;
+   struct bounce_index bnext;
 };
 
 /* In rx_buffer, we do not need multiple fragments as is a single buffer */
@@ -619,6 +631,9 @@ struct netxen_rx_buffer {
u64 dma;
u16 ref_handle;
u16 state;
+   u32 rx_bounce_buff;
+   struct bounce_index bnext;
+   char *bounce_ptr;
 };
 
 /* Board types */
@@ -703,6 +718,7 @@ struct netxen_recv_context {
 };
 
 #define NETXEN_NIC_MSI_ENABLED 0x02
+#define NETXEN_DMA_MASK0xfffe
 
 struct netxen_drvops;
 
@@ -937,9 +953,7 @@ static inline void netxen_nic_disable_in
/*
 * ISR_INT_MASK: Can be read from window 0 or 1.
 */
-   writel(0x7ff,
-  (void __iomem
-   *)(PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK)));
+   writel(0x7ff, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
 
 }
 
@@ -959,14 +973,12 @@ static inline void netxen_nic_enable_int
break;
}
 
-   writel(mask,
-  (void __iomem
-   *)(PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK)));
+   writel(mask, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
 
if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
mask = 0xbff;
-   writel(mask, (void __iomem *)
-  (PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_TARGET_MASK)));
+   writel(mask, PCI_OFFSET_SECOND_RANGE(adapter,
+ISR_INT_TARGET_MASK));
}
 }
 
@@ -1040,6 +1052,9 @@ static inline void get_brd_name_by_type(
 
 int netxen_is_flash_supported(struct netxen_adapter *adapter);
 int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]);
+int netxen_get_next_bounce_buffer(struct bounce_index *head,
+ struct bounce_index *tail,
+ struct bounce_index *biret, unsigned len);
 
 extern void netxen_change_ringparam(struct netxen_adapter *adapter);
 extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr,
diff --git a/dr

[PATCH 1/3] NetXen: Fixed /sys mapping between device and driver

2006-11-17 Thread Linsys Contractor Amit S. Kale
Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

 netxen_nic_main.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index 145bf47..a055208 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -273,6 +273,7 @@ netxen_nic_probe(struct pci_dev *pdev, c
}
 
SET_MODULE_OWNER(netdev);
+   SET_NETDEV_DEV(netdev, &pdev->dev);
 
port = netdev_priv(netdev);
port->netdev = netdev;
@@ -1043,7 +1044,7 @@ static int netxen_nic_poll(struct net_de
netxen_nic_enable_int(adapter);
}
 
-   return (done ? 0 : 1);
+   return (!done);
 }
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] NetXen: 1G/10G Ethernet Driver updates

2006-11-17 Thread Linsys Contractor Amit S. Kale
Thanks Jeff,

We have rebased last sent patches wrt current upstream branch. I will be 
sending them shortly.

--Amit
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] NetXen: Fixed /sys mapping between device and driver

2006-11-07 Thread Amit S. Kale
Hi Ingo,

Will do.
Thanks for reviewing it.
-Amit

On Tuesday 07 November 2006 22:19, Ingo Oeser wrote:
> Hi Amit,
>
> one minor nitpick:
>
> You wrote:
> > diff --git a/drivers/net/netxen/netxen_nic_main.c
> > b/drivers/net/netxen/netxen_nic_main.c index b54ea16..4effb87 100644
> > --- a/drivers/net/netxen/netxen_nic_main.c
> > +++ b/drivers/net/netxen/netxen_nic_main.c
>
> [...]
>
> > @@ -1040,7 +1041,7 @@ static int netxen_nic_poll(struct net_de
> > netxen_nic_enable_int(adapter);
> > }
> >
> > -   return (done ? 0 : 1);
> > +   return (!done);
>
>   return !done;
>
> Please lose the braces here (CodingStyle).
>
> Just respin or send this change along with later patchsets.
>
> Regards
>
> Ingo Oeser
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] NetXen: 1G/10G Ethernet Driver updates

2006-11-07 Thread Amit S. Kale


NetXen: 1G/10G Ethernet Driver updates
- Driver cleanup
- These fixes take care of driver on machines with >4G memory

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

 netxen_nic.h  |   41 ++
 netxen_nic_ethtool.c  |   19 ++--
 netxen_nic_hdr.h  |0
 netxen_nic_hw.c   |   10 +-
 netxen_nic_hw.h   |4
 netxen_nic_init.c |   51 +++-
 netxen_nic_ioctl.h|0
 netxen_nic_isr.c  |3
 netxen_nic_main.c |  204 +++---
 netxen_nic_niu.c  |0
 netxen_nic_phan_reg.h |   10 +-
 11 files changed, 293 insertions(+), 49 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index d0d9a29..104f60d 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -6,12 +6,12 @@
  * 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,
@@ -90,8 +90,8 @@ #define ADDR_IN_WINDOW1(off)  \
  * normalize a 64MB crb address to 32MB PCI window
  * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1
  */
-#define NETXEN_CRB_NORMAL(reg)\
-   (reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST
+#define NETXEN_CRB_NORMAL(reg) \
+   ((reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)

 #define NETXEN_CRB_NORMALIZE(adapter, reg) \
pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg))
@@ -165,7 +165,7 @@ #define RCV_DESC_TYPE(ID) \

 #define MAX_CMD_DESCRIPTORS1024
 #define MAX_RCV_DESCRIPTORS32768
-#define MAX_JUMBO_RCV_DESCRIPTORS  1024
+#define MAX_JUMBO_RCV_DESCRIPTORS  4096
 #define MAX_RCVSTATUS_DESCRIPTORS  MAX_RCV_DESCRIPTORS
 #define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS
 #define MAX_RCV_DESC   MAX_RCV_DESCRIPTORS
@@ -593,6 +593,16 @@ struct netxen_skb_frag {
u32 length;
 };

+/* Bounce buffer index */
+struct bounce_index {
+   /* Index of a buffer */
+   unsigned buffer_index;
+   /* Offset inside the buffer */
+   unsigned buffer_offset;
+};
+
+#define IS_BOUNCE 0xcafebb
+
 /*Following defines are for the state of the buffers*/
 #defineNETXEN_BUFFER_FREE  0
 #defineNETXEN_BUFFER_BUSY  1
@@ -612,6 +622,8 @@ struct netxen_cmd_buffer {
unsigned long time_stamp;
u32 state;
u32 no_of_descriptors;
+   u32 tx_bounce_buff;
+   struct bounce_index bnext;
 };

 /* In rx_buffer, we do not need multiple fragments as is a single buffer */
@@ -620,6 +632,9 @@ struct netxen_rx_buffer {
u64 dma;
u16 ref_handle;
u16 state;
+   u32 rx_bounce_buff;
+   struct bounce_index bnext;
+   char *bounce_ptr;
 };

 /* Board types */
@@ -704,6 +719,7 @@ struct netxen_recv_context {
 };

 #define NETXEN_NIC_MSI_ENABLED 0x02
+#define NETXEN_DMA_MASK0xfffe

 struct netxen_drvops;

@@ -938,9 +954,7 @@ static inline void netxen_nic_disable_in
/*
 * ISR_INT_MASK: Can be read from window 0 or 1.
 */
-   writel(0x7ff,
-  (void __iomem
-   *)(PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK)));
+   writel(0x7ff, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));

 }

@@ -960,14 +974,12 @@ static inline void netxen_nic_enable_int
break;
}

-   writel(mask,
-  (void __iomem
-   *)(PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK)));
+   writel(mask, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));

if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
mask = 0xbff;
-   writel(mask, (void __iomem *)
-  (PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_TARGET_MASK)));
+   writel(mask, PCI_OFFSET_SECOND_RANGE(adapter,
+ISR_INT_TARGET_MASK));
}
 }

@@ -1041,6 +1053,9 @@ static inline void get_brd_name_by_type(

 int netxen_is_flash_supported(struct netxen_adapter *adapter);
 int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]);
+int netxen_get_next_bounce_buffer(struct bounce_index *head,
+ struct bounce_index *tail,
+ struct bounce_index *biret, unsigned len);

 extern void netxen_change_ringparam(struct netxen_adapter *adapter);
 extern int netxen_rom_fast_read(struc

[PATCH 1/3] NetXen: Fixed /sys mapping between device and driver

2006-11-07 Thread Amit S. Kale


Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

 netxen_nic_main.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index b54ea16..4effb87 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -270,6 +270,7 @@ netxen_nic_probe(struct pci_dev *pdev, c
}

SET_MODULE_OWNER(netdev);
+   SET_NETDEV_DEV(netdev, &pdev->dev);

port = netdev_priv(netdev);
port->netdev = netdev;
@@ -1040,7 +1041,7 @@ static int netxen_nic_poll(struct net_de
netxen_nic_enable_int(adapter);
}

-   return (done ? 0 : 1);
+   return (!done);
 }

 #ifdef CONFIG_NET_POLL_CONTROLLER
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] NetXen: 1G/10G Ethernet Driver updates

2006-11-07 Thread Amit S. Kale

Hi All,

I will be sending NetXen 1G/10G ethernet driver updates in subsequent 
emails. Kindly review it and feel free to send feedback.


Thanks,
--Amit

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


[PATCH 2.6.18 9/9] NetXen: CRB reg definitions

2006-09-27 Thread Amit S. Kale

diff -Narup -X linux-2.6.18.orig/Documentation/dontdiff 
linux-2.6.18.orig/drivers/net/netxen/netxen_nic_phan_reg.h 
linux-2.6.18/drivers/net/netxen/netxen_nic_phan_reg.h
--- linux-2.6.18.orig/drivers/net/netxen/netxen_nic_phan_reg.h  1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18/drivers/net/netxen/netxen_nic_phan_reg.h   2006-09-25 
05:04:07.0 -0700
@@ -0,0 +1,195 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#ifndef __NIC_PHAN_REG_H_
+#define __NIC_PHAN_REG_H_
+
+/* 
+ * CRB Registers or queue message done only at initialization time.

+ */
+
+/*
+ * The following 2 are the base adresses for the CRB registers and their
+ * offsets will be added to get addresses for the index addresses.
+ */
+#define NIC_CRB_BASE_PORT1 NETXEN_CAM_RAM(0x200)
+#define NIC_CRB_BASE_PORT2 NETXEN_CAM_RAM(0x250)
+
+#define NETXEN_NIC_REG(X)  (NIC_CRB_BASE_PORT1+(X))
+
+/*
+ * CrbPortPhanCntrHi/Lo is used to pass the address of HostPhantomIndex address
+ * which can be read by the Phantom host to get producer/consumer indexes from
+ * Phantom/Casper. If it is not HOST_SHARED_MEMORY, then the following
+ * registers will be used for the addresses of the ring's shared memory
+ * on the Phantom.
+ */
+
+#define CRB_PHAN_CNTRL_LO_OFFSET   NETXEN_NIC_REG(0x00)
+#define CRB_PHAN_CNTRL_HI_OFFSET   NETXEN_NIC_REG(0x04)
+
+/* point to the indexes */
+#define CRB_CMD_PRODUCER_OFFSETNETXEN_NIC_REG(0x08)
+#define CRB_CMD_CONSUMER_OFFSETNETXEN_NIC_REG(0x0c)
+
+/* address of command descriptors in the host memory */
+#define CRB_HOST_CMD_ADDR_HI   NETXEN_NIC_REG(0x30)
+#define CRB_HOST_CMD_ADDR_LO   NETXEN_NIC_REG(0x34)
+
+/* The following 4 CRB registers are for doing performance coal */
+#define CRB_CMD_INTR_LOOP  NETXEN_NIC_REG(0x38)
+#define CRB_CMD_DMA_LOOP   NETXEN_NIC_REG(0x3c)
+#define CRB_RCV_INTR_LOOP  NETXEN_NIC_REG(0x40)
+#define CRB_RCV_DMA_LOOP   NETXEN_NIC_REG(0x44)
+
+/* Needed by the host to find out the state of Phantom's initialization */
+#define CRB_ENABLE_TX_INTR NETXEN_NIC_REG(0x4c)
+#define CRB_CMDPEG_STATE   NETXEN_NIC_REG(0x50)
+#define CRB_CMDPEG_CMDRING NETXEN_NIC_REG(0x54)
+
+/* Interrupt coalescing parameters */
+#define CRB_GLOBAL_INT_COALNETXEN_NIC_REG(0x80)
+#define CRB_INT_COAL_MODE  NETXEN_NIC_REG(0x84)
+#define CRB_MAX_RCV_BUFS   NETXEN_NIC_REG(0x88)
+#define CRB_TX_INT_THRESHOLD   NETXEN_NIC_REG(0x8c)
+#define CRB_RX_PKT_TIMER   NETXEN_NIC_REG(0x90)
+#define CRB_TX_PKT_TIMER   NETXEN_NIC_REG(0x94)
+#define CRB_RX_PKT_CNT NETXEN_NIC_REG(0x98)
+#define CRB_RX_TMR_CNT NETXEN_NIC_REG(0x9c)
+
+/* Register for communicating XG link status */
+#define CRB_XG_STATE   NETXEN_NIC_REG(0xa0)
+
+/* Debug registers for controlling NIC pkt gen agent */
+#define CRB_AGENT_GO   NETXEN_NIC_REG(0xb0)
+#define CRB_AGENT_TX_SIZE  NETXEN_NIC_REG(0xb4)
+#define CRB_AGENT_TX_TYPE  NETXEN_NIC_REG(0xb8)
+#define CRB_AGENT_TX_ADDR  NETXEN_NIC_REG(0xbc)
+#define CRB_AGENT_TX_MSS   NETXEN_NIC_REG(0xc0)
+
+/* Debug registers for observing NIC performance */
+#define CRB_TX_STATE   NETXEN_NIC_REG(0xd0)
+#define CRB_TX_COUNT   NETXEN_NIC_REG(0xd4)
+#define CRB_RX_STATE   NETXEN_NIC_REG(0xd8)
+
+/* CRB registers per Rcv Descriptor ring */
+struct netxen_rcv_desc_crb {
+   u32 crb_rcv_producer_offset __attribute__ ((aligned(512)));
+   u32 crb_rcv_consumer_offset;
+   u32 crb_globalrcv_ring;
+};
+
+/*
+ * CRB registers used by the receive peg logic. One instance of these
+ * needs to be instantiated per instance of the receive peg.
+ */
+
+struct netxen_recv_crb {
+   struct netxen_rcv_desc_crb rcv_desc_crb[NUM_RCV_DESC_RINGS];

[PATCH 2.6.18 8/9] NetXen: Header file and ioctl header file

2006-09-27 Thread Amit S. Kale

diff -Narup -X linux-2.6.18.orig/Documentation/dontdiff 
linux-2.6.18.orig/drivers/net/netxen/netxen_nic_hdr.h 
linux-2.6.18/drivers/net/netxen/netxen_nic_hdr.h
--- linux-2.6.18.orig/drivers/net/netxen/netxen_nic_hdr.h   1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18/drivers/net/netxen/netxen_nic_hdr.h2006-09-25 
05:04:07.0 -0700
@@ -0,0 +1,618 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#ifndef __NETXEN_NIC_HDR_H_
+#define __NETXEN_NIC_HDR_H_
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include   /* for memset */
+
+/*
+ * The basic unit of access when reading/writing control registers.
+ */
+
+typedef __le32 netxen_crbword_t;   /* single word in CRB space */
+
+enum {
+   NETXEN_HW_H0_CH_HUB_ADR = 0x05,
+   NETXEN_HW_H1_CH_HUB_ADR = 0x0E,
+   NETXEN_HW_H2_CH_HUB_ADR = 0x03,
+   NETXEN_HW_H3_CH_HUB_ADR = 0x01,
+   NETXEN_HW_H4_CH_HUB_ADR = 0x06,
+   NETXEN_HW_H5_CH_HUB_ADR = 0x07,
+   NETXEN_HW_H6_CH_HUB_ADR = 0x08
+};
+
+/*  Hub 0 */
+enum {
+   NETXEN_HW_MN_CRB_AGT_ADR = 0x15,
+   NETXEN_HW_MS_CRB_AGT_ADR = 0x25
+};
+
+/*  Hub 1 */
+enum {
+   NETXEN_HW_PS_CRB_AGT_ADR = 0x73,
+   NETXEN_HW_SS_CRB_AGT_ADR = 0x20,
+   NETXEN_HW_RPMX3_CRB_AGT_ADR = 0x0b,
+   NETXEN_HW_QMS_CRB_AGT_ADR = 0x00,
+   NETXEN_HW_SQGS0_CRB_AGT_ADR = 0x01,
+   NETXEN_HW_SQGS1_CRB_AGT_ADR = 0x02,
+   NETXEN_HW_SQGS2_CRB_AGT_ADR = 0x03,
+   NETXEN_HW_SQGS3_CRB_AGT_ADR = 0x04,
+   NETXEN_HW_C2C0_CRB_AGT_ADR = 0x58,
+   NETXEN_HW_C2C1_CRB_AGT_ADR = 0x59,
+   NETXEN_HW_C2C2_CRB_AGT_ADR = 0x5a,
+   NETXEN_HW_RPMX2_CRB_AGT_ADR = 0x0a,
+   NETXEN_HW_RPMX4_CRB_AGT_ADR = 0x0c,
+   NETXEN_HW_RPMX7_CRB_AGT_ADR = 0x0f,
+   NETXEN_HW_RPMX9_CRB_AGT_ADR = 0x12,
+   NETXEN_HW_SMB_CRB_AGT_ADR = 0x18
+};
+
+/*  Hub 2 */
+enum {
+   NETXEN_HW_NIU_CRB_AGT_ADR = 0x31,
+   NETXEN_HW_I2C0_CRB_AGT_ADR = 0x19,
+   NETXEN_HW_I2C1_CRB_AGT_ADR = 0x29,
+
+   NETXEN_HW_SN_CRB_AGT_ADR = 0x10,
+   NETXEN_HW_I2Q_CRB_AGT_ADR = 0x20,
+   NETXEN_HW_LPC_CRB_AGT_ADR = 0x22,
+   NETXEN_HW_ROMUSB_CRB_AGT_ADR = 0x21,
+   NETXEN_HW_QM_CRB_AGT_ADR = 0x66,
+   NETXEN_HW_SQG0_CRB_AGT_ADR = 0x60,
+   NETXEN_HW_SQG1_CRB_AGT_ADR = 0x61,
+   NETXEN_HW_SQG2_CRB_AGT_ADR = 0x62,
+   NETXEN_HW_SQG3_CRB_AGT_ADR = 0x63,
+   NETXEN_HW_RPMX1_CRB_AGT_ADR = 0x09,
+   NETXEN_HW_RPMX5_CRB_AGT_ADR = 0x0d,
+   NETXEN_HW_RPMX6_CRB_AGT_ADR = 0x0e,
+   NETXEN_HW_RPMX8_CRB_AGT_ADR = 0x11
+};
+
+/*  Hub 3 */
+enum {
+   NETXEN_HW_PH_CRB_AGT_ADR = 0x1A,
+   NETXEN_HW_SRE_CRB_AGT_ADR = 0x50,
+   NETXEN_HW_EG_CRB_AGT_ADR = 0x51,
+   NETXEN_HW_RPMX0_CRB_AGT_ADR = 0x08
+};
+
+/*  Hub 4 */
+enum {
+   NETXEN_HW_PEGN0_CRB_AGT_ADR = 0x40,
+   NETXEN_HW_PEGN1_CRB_AGT_ADR,
+   NETXEN_HW_PEGN2_CRB_AGT_ADR,
+   NETXEN_HW_PEGN3_CRB_AGT_ADR,
+   NETXEN_HW_PEGNI_CRB_AGT_ADR,
+   NETXEN_HW_PEGND_CRB_AGT_ADR,
+   NETXEN_HW_PEGNC_CRB_AGT_ADR,
+   NETXEN_HW_PEGR0_CRB_AGT_ADR,
+   NETXEN_HW_PEGR1_CRB_AGT_ADR,
+   NETXEN_HW_PEGR2_CRB_AGT_ADR,
+   NETXEN_HW_PEGR3_CRB_AGT_ADR
+};
+
+/*  Hub 5 */
+enum {
+   NETXEN_HW_PEGS0_CRB_AGT_ADR = 0x40,
+   NETXEN_HW_PEGS1_CRB_AGT_ADR,
+   NETXEN_HW_PEGS2_CRB_AGT_ADR,
+   NETXEN_HW_PEGS3_CRB_AGT_ADR,
+   NETXEN_HW_PEGSI_CRB_AGT_ADR,
+   NETXEN_HW_PEGSD_CRB_AGT_ADR,
+   NETXEN_HW_PEGSC_CRB_AGT_ADR
+};
+
+/*  Hub 6 */
+enum {
+   NETXEN_HW_CAS0_CRB_AGT_ADR = 0x46,
+   NETXEN_HW_CAS1_CRB_AGT_ADR = 0x47,
+   NETXEN_HW_CAS2_CRB_AGT_ADR = 0x48,
+   NETXEN_HW_CAS3_CRB_AGT_ADR = 0x49,
+   NETXEN_HW_NCM_CRB_AGT_ADR = 0x16,
+   NETXEN_HW_TMR_CRB_AGT_ADR = 0x17,
+   NETXEN_HW_XDMA_CRB_AGT_ADR = 0x05,
+   NETXEN_HW_OCM0_CRB_AGT_ADR = 0x06,
+   NETXEN_HW_OCM1_CRB_AGT_ADR = 0x07
+};

[PATCH 2.6.18 7/9] NetXen: hw access routines header file

2006-09-27 Thread Amit S. Kale

diff -Narup -X linux-2.6.18.orig/Documentation/dontdiff 
linux-2.6.18.orig/drivers/net/netxen/netxen_nic_hw.h 
linux-2.6.18/drivers/net/netxen/netxen_nic_hw.h
--- linux-2.6.18.orig/drivers/net/netxen/netxen_nic_hw.h1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18/drivers/net/netxen/netxen_nic_hw.h 2006-09-25 
05:04:07.0 -0700
@@ -0,0 +1,480 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * Structures, enums, and macros for the MAC
+ *
+ */
+
+#ifndef __NETXEN_NIC_HW_H_
+#define __NETXEN_NIC_HW_H_
+
+#include "netxen_nic_hdr.h"
+
+/* Hardware memory size of 128 meg */
+#define NETXEN_MEMADDR_MAX (128 * 1024 * 1024)
+
+#ifndef readq
+static inline u64 readq(void __iomem * addr)
+{
+   return readl(addr) | (((u64) readl(addr + 4)) << 32LL);
+}
+#endif
+
+#ifndef writeq
+static inline void writeq(u64 val, void __iomem * addr)
+{
+   writel(((u32) (val)), (addr));
+   writel(((u32) (val >> 32)), (addr + 4));
+}
+#endif
+
+static inline void netxen_nic_hw_block_write64(u64 __iomem * data_ptr,
+  u64 __iomem * addr,
+  int num_words)
+{
+   int num;
+   for (num = 0; num < num_words; num++) {
+   writeq(readq((void __iomem *)data_ptr), addr);
+   addr++;
+   data_ptr++;
+   }
+}
+
+static inline void netxen_nic_hw_block_read64(u64 __iomem * data_ptr,
+ u64 __iomem * addr, int num_words)
+{
+   int num;
+   for (num = 0; num < num_words; num++) {
+   writeq(readq((void __iomem *)addr), data_ptr);
+   addr++;
+   data_ptr++;
+   }
+
+}
+
+struct netxen_adapter;
+
+#define NETXEN_PCI_MAPSIZE_BYTES  (NETXEN_PCI_MAPSIZE << 20)
+
+#define NETXEN_NIC_LOCKED_READ_REG(X, Y)   \
+   addr = (adapter->ahw.pci_base + X); \
+   *(u32 *)Y = readl((void __iomem*) addr);
+
+struct netxen_port;
+void netxen_nic_set_link_parameters(struct netxen_port *port);
+void netxen_nic_flash_print(struct netxen_adapter *adapter);
+int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off,
+  void *data, int len);
+void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
+unsigned long off, int data);
+int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off,
+ void *data, int len);
+
+typedef u8 netxen_ethernet_macaddr_t[6];
+
+/* Nibble or Byte mode for phy interface (GbE mode only) */
+typedef enum {
+   NETXEN_NIU_10_100_MB = 0,
+   NETXEN_NIU_1000_MB
+} netxen_niu_gbe_ifmode_t;
+
+#define _netxen_crb_get_bit(var, bit)  ((var >> bit) & 0x1)
+
+/*
+ * NIU GB MAC Config Register 0 (applies to GB0, GB1, GB2, GB3)
+ *
+ * Bit 0 : enable_tx => 1:enable frame xmit, 0:disable
+ * Bit 1 : tx_synced => R/O: xmit enable synched to xmit stream
+ * Bit 2 : enable_rx => 1:enable frame recv, 0:disable
+ * Bit 3 : rx_synced => R/O: recv enable synched to recv stream
+ * Bit 4 : tx_flowctl => 1:enable pause frame generation, 0:disable
+ * Bit 5 : rx_flowctl => 1:act on recv'd pause frames, 0:ignore
+ * Bit 8 : loopback => 1:loop MAC xmits to MAC recvs, 0:normal
+ * Bit 16: tx_reset_pb => 1:reset frame xmit protocol blk, 0:no-op
+ * Bit 17: rx_reset_pb => 1:reset frame recv protocol blk, 0:no-op
+ * Bit 18: tx_reset_mac => 1:reset data/ctl multiplexer blk, 0:no-op
+ * Bit 19: rx_reset_mac => 1:reset ctl frames & timers blk, 0:no-op
+ * Bit 31: soft_reset => 1:reset the MAC and the SERDES, 0:no-op
+ */
+
+#define netxen_gb_enable_tx(config_word)   \
+   set_bit(0, (unsigned long*)(&config_word))
+#define netxen_gb_enable_rx(config_word)   \
+   set_bit(2, (unsigned long*)(&config_word))
+#define netxen_gb_tx_flowctl(config_word)  \
+   set_bit(4, (unsigned long*)(&config_word))
+

[PATCH 2.6.18 6/9] NetXen: Main header file

2006-09-27 Thread Amit S. Kale

diff -Narup -X linux-2.6.18.orig/Documentation/dontdiff 
linux-2.6.18.orig/drivers/net/netxen/netxen_nic.h 
linux-2.6.18/drivers/net/netxen/netxen_nic.h
--- linux-2.6.18.orig/drivers/net/netxen/netxen_nic.h   1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18/drivers/net/netxen/netxen_nic.h2006-09-25 
05:04:07.0 -0700
@@ -0,0 +1,910 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#ifndef _NETXEN_NIC_H_
+#define _NETXEN_NIC_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "netxen_nic_hw.h"
+
+#define NETXEN_NIC_BUILD_NO "232"
+#define _NETXEN_NIC_LINUX_MAJOR 2
+#define _NETXEN_NIC_LINUX_MINOR 3
+#define _NETXEN_NIC_LINUX_SUBVERSION 57
+#define NETXEN_NIC_LINUX_VERSIONID  "2.3.57"
+#define NETXEN_NIC_FW_VERSIONID "2.3.57"
+
+#define RCV_DESC_RINGSIZE  \
+   (sizeof(struct rcv_desc) * adapter->max_rx_desc_count)
+#define STATUS_DESC_RINGSIZE   \
+   (sizeof(struct status_desc)* adapter->max_rx_desc_count)
+#define TX_RINGSIZE\
+   (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count)
+#define RCV_BUFFSIZE   \
+   (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count)
+#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) \
+   ((adapter)->ahw.pci_base + (reg) \
+   - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)
+
+#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)
+#define NETXEN_ROM_ROUNDUP 0x8000ULL
+
+/*
+ * Maximum number of ring contexts
+ */
+#define MAX_RING_CTX 1
+
+/* Opcodes to be used with the commands */
+enum {
+   TX_ETHER_PKT = 0x01,
+/* The following opcodes are for IP checksum   */
+   TX_TCP_PKT,
+   TX_UDP_PKT,
+   TX_IP_PKT,
+   TX_TCP_LSO,
+   TX_IPSEC,
+   TX_IPSEC_CMD
+};
+
+/* The following opcodes are for internal consumption. */
+#define NETXEN_CONTROL_OP  0x10
+#define PEGNET_REQUEST 0x11
+
+#defineMAX_NUM_CARDS   4
+
+#define MAX_BUFFERS_PER_CMD32
+
+/*
+ * 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 0x
+#define PHAN_INITIALIZE_COMPLETE   0xff01
+
+/* Host writes the following to notify that it has done the init-handshake */
+#define PHAN_INITIALIZE_ACK0xf00f
+
+#define NUM_RCV_DESC_RINGS 2   /* No of Rcv Descriptor contexts */
+
+/* descriptor types */
+#define RCV_DESC_NORMAL0x01
+#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_DESCRIPTORS1024
+#define MAX_RCV_DESCRIPTORS32768
+#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 

[PATCH 2.6.18 5/9] NetXen: ethtool interface

2006-09-27 Thread Amit S. Kale

diff -Narup -X linux-2.6.18.orig/Documentation/dontdiff 
linux-2.6.18.orig/drivers/net/netxen/netxen_nic_ethtool.c 
linux-2.6.18/drivers/net/netxen/netxen_nic_ethtool.c
--- linux-2.6.18.orig/drivers/net/netxen/netxen_nic_ethtool.c   1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18/drivers/net/netxen/netxen_nic_ethtool.c2006-09-25 
05:04:07.0 -0700
@@ -0,0 +1,715 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * ethtool support for netxen nic
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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(__le32))
+#define NETXEN_MAX_EEPROM_LEN   1024
+
+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 & NETXEN_ROM_ROUNDUP)) {
+   n &= ~NETXEN_ROM_ROUNDUP;
+   if (n < NETXEN_MAX_EEPROM_LEN)
+   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);
+   struct netxen_adapter *adapter = port->adapter;
+   uint32_t fw_major = 0;
+   uint32_t fw_minor = 0;
+   uint32_t fw_build = 0;
+
+   strncpy(drvinfo->driver, "netxen_nic", 32);
+   strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32);
+   fw_major = readl(NETXEN_CRB_NORMALIZE(adapter,
+ NETXEN_FW_VERSION_MAJOR));
+   fw_minor = readl(NETXEN_CRB_NORMALIZE(adapter,
+ NETXEN_FW_VERSION_MINOR));
+   fw_build = readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_FW_VERSION_SUB));
+   sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build);

[PATCH 2.6.18 3/9] NetXen: hw initialization routines

2006-09-27 Thread Amit S. Kale

diff -Narup -X linux-2.6.18.orig/Documentation/dontdiff 
linux-2.6.18.orig/drivers/net/netxen/netxen_nic_init.c 
linux-2.6.18/drivers/net/netxen/netxen_nic_init.c
--- linux-2.6.18.orig/drivers/net/netxen/netxen_nic_init.c  1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18/drivers/net/netxen/netxen_nic_init.c   2006-09-25 
05:04:07.0 -0700
@@ -0,0 +1,1143 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * Source file for NIC routines to initialize the Phantom Hardware
+ *
+ */
+
+#include 
+#include 
+#include "netxen_nic.h"
+#include "netxen_nic_hw.h"
+#include "netxen_nic_ioctl.h"
+#include "netxen_nic_phan_reg.h"
+
+struct crb_addr_pair {
+   long addr;
+   long data;
+};
+
+#define NETXEN_MAX_CRB_XFORM 60
+static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM];
+#define NETXEN_ADDR_ERROR ((unsigned long ) 0x )
+
+#define crb_addr_transform(name) \
+   crb_addr_xform[NETXEN_HW_PX_MAP_CRB_##name] = \
+   NETXEN_HW_CRB_HUB_AGT_ADR_##name << 20
+
+static inline void
+netxen_nic_locked_write_reg(struct netxen_adapter *adapter,
+   unsigned long off, int *data)
+{
+   void __iomem *addr = (adapter->ahw.pci_base + off);
+   writel(*data, addr);
+}
+
+static void crb_addr_transform_setup(void)
+{
+   crb_addr_transform(XDMA);
+   crb_addr_transform(TIMR);
+   crb_addr_transform(SRE);
+   crb_addr_transform(SQN3);
+   crb_addr_transform(SQN2);
+   crb_addr_transform(SQN1);
+   crb_addr_transform(SQN0);
+   crb_addr_transform(SQS3);
+   crb_addr_transform(SQS2);
+   crb_addr_transform(SQS1);
+   crb_addr_transform(SQS0);
+   crb_addr_transform(RPMX7);
+   crb_addr_transform(RPMX6);
+   crb_addr_transform(RPMX5);
+   crb_addr_transform(RPMX4);
+   crb_addr_transform(RPMX3);
+   crb_addr_transform(RPMX2);
+   crb_addr_transform(RPMX1);
+   crb_addr_transform(RPMX0);
+   crb_addr_transform(ROMUSB);
+   crb_addr_transform(SN);
+   crb_addr_transform(QMN);
+   crb_addr_transform(QMS);
+   crb_addr_transform(PGNI);
+   crb_addr_transform(PGND);
+   crb_addr_transform(PGN3);
+   crb_addr_transform(PGN2);
+   crb_addr_transform(PGN1);
+   crb_addr_transform(PGN0);
+   crb_addr_transform(PGSI);
+   crb_addr_transform(PGSD);
+   crb_addr_transform(PGS3);
+   crb_addr_transform(PGS2);
+   crb_addr_transform(PGS1);
+   crb_addr_transform(PGS0);
+   crb_addr_transform(PS);
+   crb_addr_transform(PH);
+   crb_addr_transform(NIU);
+   crb_addr_transform(I2Q);
+   crb_addr_transform(EG);
+   crb_addr_transform(MN);
+   crb_addr_transform(MS);
+   crb_addr_transform(CAS2);
+   crb_addr_transform(CAS1);
+   crb_addr_transform(CAS0);
+   crb_addr_transform(CAM);
+   crb_addr_transform(C2C1);
+   crb_addr_transform(C2C0);
+}
+
+int netxen_init_firmware(struct netxen_adapter *adapter)
+{
+   u32 state = 0, loops = 0, err = 0;
+
+   /* Window 1 call */
+   state = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
+
+   if (state == PHAN_INITIALIZE_ACK)
+   return 0;
+
+   while (state != PHAN_INITIALIZE_COMPLETE && loops < 2000) {
+   udelay(100);
+   /* Window 1 call */
+   state = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
+
+   loops++;
+   }
+   if (loops >= 2000) {
+   printk(KERN_ERR "Cmd Peg initialization not complete:%x.\n",
+  state);
+   err = -EIO;
+   return err;
+   }
+   /* Window 1 call */
+   writel(PHAN_INITIALIZE_ACK,
+  NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
+
+   return err;
+}
+
+void netxen_initialize_adapter_sw(struct netxen_adapter *adapter)
+{
+   int ctxid, ring;
+   u32 i;
+   u32 num_rx_bufs = 0;
+   struct netxen_rcv_desc_ctx *

[PATCH 2.6.18 4/9] NetXen: intr routines and niu handling

2006-09-27 Thread Amit S. Kale

diff -Narup -X linux-2.6.18.orig/Documentation/dontdiff 
linux-2.6.18.orig/drivers/net/netxen/netxen_nic_isr.c 
linux-2.6.18/drivers/net/netxen/netxen_nic_isr.c
--- linux-2.6.18.orig/drivers/net/netxen/netxen_nic_isr.c   1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18/drivers/net/netxen/netxen_nic_isr.c2006-09-25 
05:04:07.0 -0700
@@ -0,0 +1,221 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#include 
+#include 
+
+#include "netxen_nic.h"
+#include "netxen_nic_hw.h"
+#include "netxen_nic_phan_reg.h"
+
+/*
+ * netxen_nic_get_stats - Get System Network Statistics
+ * @netdev: network interface device structure
+ */
+struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct net_device_stats *stats = &port->net_stats;
+
+   memset(stats, 0, sizeof(*stats));
+
+   /* total packets received   */
+   stats->rx_packets = port->stats.no_rcv;
+   /* total packets transmitted*/
+   stats->tx_packets = port->stats.xmitedframes + port->stats.xmitfinished;
+   /* total bytes received */
+   stats->rx_bytes = port->stats.rxbytes;
+   /* total bytes transmitted  */
+   stats->tx_bytes = port->stats.txbytes;
+   /* bad packets received */
+   stats->rx_errors = port->stats.rcvdbadskb;
+   /* packet transmit problems */
+   stats->tx_errors = port->stats.nocmddescriptor;
+   /* no space in linux buffers*/
+   stats->rx_dropped = port->stats.updropped;
+   /* no space available in linux  */
+   stats->tx_dropped = port->stats.txdropped;
+
+   return stats;
+}
+
+void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno,
+u32 link)
+{
+   struct netxen_port *pport = adapter->port[portno];
+   struct net_device *netdev = pport->netdev;
+
+   if (link)
+   netif_carrier_on(netdev);
+   else
+   netif_carrier_off(netdev);
+}
+
+void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno,
+   u32 enable)
+{
+   __le32 int_src;
+   struct netxen_port *port;
+
+   /*  This should clear the interrupt source */
+   if (adapter->ops->phy_read)
+   adapter->ops->phy_read(adapter, portno,
+  NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
+  &int_src);
+   if (int_src == 0) {
+   DPRINTK(INFO, "No phy interrupts for port #%d\n", portno);
+   return;
+   }
+   if (adapter->ops->disable_phy_interrupts)
+   adapter->ops->disable_phy_interrupts(adapter, portno);
+
+   port = adapter->port[portno];
+
+   if (netxen_get_phy_int_jabber(int_src))
+   DPRINTK(INFO, "NetXen: %s Jabber interrupt \n",
+   port->netdev->name);
+
+   if (netxen_get_phy_int_polarity_changed(int_src))
+   DPRINTK(INFO, "NetXen: %s POLARITY CHANGED int \n",
+   port->netdev->name);
+
+   if (netxen_get_phy_int_energy_detect(int_src))
+   DPRINTK(INFO, "NetXen: %s ENERGY DETECT INT \n",
+   port->netdev->name);
+
+   if (netxen_get_phy_int_downshift(int_src))
+   DPRINTK(INFO, "NetXen: %s DOWNSHIFT INT \n",
+   port->netdev->name);
+   /* write it down later.. */
+   if ((netxen_get_phy_int_speed_changed(int_src))
+   || (netxen_get_phy_int_link_status_changed(int_src))) {
+   __le32 status;
+
+   DPRINTK(INFO, "NetXen: %s SPEED CHANGED OR"
+   " LINK STATUS CHANGED \n", port->netdev->name);
+
+   if (adapter->ops->phy_read
+   && adapter->ops->phy_read(adapter, portno,
+ 
NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
+ 

[PATCH 2.6.18 2/9] NetXen: Hardware access routines

2006-09-27 Thread Amit S. Kale

diff -Narup -X linux-2.6.18.orig/Documentation/dontdiff 
linux-2.6.18.orig/drivers/net/netxen/netxen_nic_hw.c 
linux-2.6.18/drivers/net/netxen/netxen_nic_hw.c
--- linux-2.6.18.orig/drivers/net/netxen/netxen_nic_hw.c1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18/drivers/net/netxen/netxen_nic_hw.c 2006-09-25 
05:04:07.0 -0700
@@ -0,0 +1,936 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * Source file for NIC routines to access the Phantom hardware
+ *
+ */
+
+#include "netxen_nic.h"
+#include "netxen_nic_hw.h"
+#include "netxen_nic_phan_reg.h"
+
+/*  PCI Windowing for DDR regions.  */
+
+#define ADDR_IN_RANGE(addr, low, high) \
+   (((addr) <= (high)) && ((addr) >= (low)))
+
+#define NETXEN_FLASH_BASE  (BOOTLD_START)
+#define NETXEN_PHANTOM_MEM_BASE(NETXEN_FLASH_BASE)
+#define NETXEN_MAX_MTU 8000
+#define NETXEN_MIN_MTU  64
+#define NETXEN_ETH_FCS_SIZE 4
+#define NETXEN_ENET_HEADER_SIZE 14
+#define NETXEN_WINDOW_ONE 0x200/* CRB Window: bit 25 of CRB address */
+#define NETXEN_FIRMWARE_LEN((16 * 1024) / 4)
+#define NETXEN_NIU_HDRSIZE (0x1 << 6)
+#define NETXEN_NIU_TLRSIZE (0x1 << 5)
+
+unsigned long netxen_nic_pci_set_window(void __iomem * pci_base,
+   unsigned long long addr);
+void netxen_free_hw_resources(struct netxen_adapter *adapter);
+
+int netxen_nic_set_mac(struct net_device *netdev, void *p)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct netxen_adapter *adapter = port->adapter;
+   struct sockaddr *addr = p;
+
+   if (netif_running(netdev))
+   return -EBUSY;
+
+   if (!is_valid_ether_addr(addr->sa_data))
+   return -EADDRNOTAVAIL;
+
+   DPRINTK(INFO, "valid ether addr\n");
+   memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
+
+   if (adapter->ops->macaddr_set)
+   adapter->ops->macaddr_set(port, addr->sa_data);
+
+   return 0;
+}
+
+/*
+ * netxen_nic_set_multi - Multicast
+ */
+void netxen_nic_set_multi(struct net_device *netdev)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct netxen_adapter *adapter = port->adapter;
+   struct dev_mc_list *mc_ptr;
+   __le32 netxen_mac_addr_cntl_data = 0;
+
+   mc_ptr = netdev->mc_list;
+   if (netdev->flags & IFF_PROMISC) {
+   if (adapter->ops->set_promisc)
+   adapter->ops->set_promisc(adapter,
+ port->portnum,
+ NETXEN_NIU_PROMISC_MODE);
+   } else {
+   if (adapter->ops->unset_promisc)
+   adapter->ops->unset_promisc(adapter,
+   port->portnum,
+   
NETXEN_NIU_NON_PROMISC_MODE);
+   }
+   if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
+   netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x03);
+   netxen_nic_mcr_set_id_pool0(netxen_mac_addr_cntl_data, 0x00);
+   netxen_nic_mcr_set_id_pool1(netxen_mac_addr_cntl_data, 0x00);
+   netxen_nic_mcr_set_id_pool2(netxen_mac_addr_cntl_data, 0x00);
+   netxen_nic_mcr_set_id_pool3(netxen_mac_addr_cntl_data, 0x00);
+   netxen_nic_mcr_set_enable_xtnd0(netxen_mac_addr_cntl_data);
+   netxen_nic_mcr_set_enable_xtnd1(netxen_mac_addr_cntl_data);
+   netxen_nic_mcr_set_enable_xtnd2(netxen_mac_addr_cntl_data);
+   netxen_nic_mcr_set_enable_xtnd3(netxen_mac_addr_cntl_data);
+   } else {
+   netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x00);
+   netxen_nic_mcr_set_id_pool0(netxen_mac_addr_cntl_data, 0x00);
+   netxen_nic_mcr_set_id_pool1(netxen_mac_addr_cntl_data, 0x01);
+   netxen_nic_mcr_set_id_pool2(netxen_mac_addr_cnt

[PATCH 2.6.18 1/9] NetXen: Makefile and driver main file

2006-09-27 Thread Amit S. Kale

diff -Narup -X linux-2.6.18.orig/Documentation/dontdiff 
linux-2.6.18.orig/MAINTAINERS linux-2.6.18/MAINTAINERS
--- linux-2.6.18.orig/MAINTAINERS   2006-09-25 02:28:24.0 -0700
+++ linux-2.6.18/MAINTAINERS2006-09-25 05:02:37.0 -0700
@@ -2060,6 +2060,13 @@ L:   netdev@vger.kernel.org
 T: git kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6.git
 S: Maintained

+NETXEN (1/10) GbE SUPPORT
+P: Amit S. Kale
+M: [EMAIL PROTECTED]
+L: netdev@vger.kernel.org
+W: http://www.netxen.com
+S: Supported
+
 IPVS
 P: Wensong Zhang
 M: [EMAIL PROTECTED]
diff -Narup -X linux-2.6.18.orig/Documentation/dontdiff 
linux-2.6.18.orig/drivers/net/Kconfig linux-2.6.18/drivers/net/Kconfig
--- linux-2.6.18.orig/drivers/net/Kconfig   2006-09-25 02:28:22.0 
-0700
+++ linux-2.6.18/drivers/net/Kconfig2006-09-25 05:03:43.0 -0700
@@ -2399,6 +2399,11 @@ config MYRI10GE
  .  The module
  will be called myri10ge.

+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 -Narup -X linux-2.6.18.orig/Documentation/dontdiff 
linux-2.6.18.orig/drivers/net/Makefile linux-2.6.18/drivers/net/Makefile
--- linux-2.6.18.orig/drivers/net/Makefile  2006-09-25 02:28:22.0 
-0700
+++ linux-2.6.18/drivers/net/Makefile   2006-09-25 05:04:07.0 -0700
@@ -219,3 +219,4 @@ obj-$(CONFIG_NETCONSOLE) += netconsole.o

 obj-$(CONFIG_FS_ENET) += fs_enet/

+obj-$(CONFIG_NETXEN_NIC) += netxen/
diff -Narup -X linux-2.6.18.orig/Documentation/dontdiff 
linux-2.6.18.orig/drivers/net/netxen/Makefile 
linux-2.6.18/drivers/net/netxen/Makefile
--- linux-2.6.18.orig/drivers/net/netxen/Makefile   1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18/drivers/net/netxen/Makefile2006-09-25 05:04:07.0 
-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:

+#[EMAIL PROTECTED]
+# 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 -Narup -X linux-2.6.18.orig/Documentation/dontdiff 
linux-2.6.18.orig/drivers/net/netxen/netxen_nic_main.c 
linux-2.6.18/drivers/net/netxen/netxen_nic_main.c
--- linux-2.6.18.orig/drivers/net/netxen/netxen_nic_main.c  1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18/drivers/net/netxen/netxen_nic_main.c   2006-09-25 
05:04:07.0 -0700
@@ -0,0 +1,1116 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ *  Main source file for NetXen NIC Driver on Linux
+ *
+ */
+
+#include "netxen_nic_hw.h"
+
+#include "netxen_nic.h"
+#define DEFINE_GLOBAL_RECV_CRB
+#include "netxen_nic_phan_reg.h"
+#include "netxen_nic_ioctl.h"
+
+MODULE_DESCRIPTION("N

[PATCH 2.6.18 0/9] NetXen: 1G/10G Ethernet Driver

2006-09-27 Thread Amit S. Kale

Hi All,

We have incorporated feedbacks which we received since last post. I'll be 
sending updated patchset wrt 2.6.18 in subsequent emails.


Thanks,
-Amit

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

 MAINTAINERS  |7
 drivers/net/Kconfig  |5
 drivers/net/Makefile |1
 drivers/net/netxen/Makefile  |   35
 drivers/net/netxen/netxen_nic.h  |  910 
 drivers/net/netxen/netxen_nic_ethtool.c  |  715 +++
 drivers/net/netxen/netxen_nic_hdr.h  |  618 
 drivers/net/netxen/netxen_nic_hw.c   |  936 +
 drivers/net/netxen/netxen_nic_hw.h   |  480 +
 drivers/net/netxen/netxen_nic_init.c | 1143 +++
 drivers/net/netxen/netxen_nic_ioctl.h|   75 ++
 drivers/net/netxen/netxen_nic_isr.c  |  221 +
 drivers/net/netxen/netxen_nic_main.c | 1116 ++
 drivers/net/netxen/netxen_nic_niu.c  |  800 +
 drivers/net/netxen/netxen_nic_phan_reg.h |  195 +
 15 files changed, 7257 insertions(+)
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2.6.18-rc7 9/9] NetXen: CRB reg definitions

2006-09-15 Thread Amit S. Kale

diff -Narup -X linux-2.6.18-rc7.orig/Documentation/dontdiff 
linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_phan_reg.h 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_phan_reg.h
--- linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_phan_reg.h  
1969-12-31 16:00:00.0 -0800
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_phan_reg.h   2006-09-15 
10:51:59.0 -0700
@@ -0,0 +1,195 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#ifndef __NIC_PHAN_REG_H_
+#define __NIC_PHAN_REG_H_
+
+/** 
+ * CRB Registers or queue message done only at initialization time

+ **/
+
+/**
+ * The following 2 are the base adresses for the CRB registers and their
+ * offsets will be added to get addresses for the index addresses...
+ **/
+#define NIC_CRB_BASE_PORT1 NETXEN_CAM_RAM(0x200)
+#define NIC_CRB_BASE_PORT2 NETXEN_CAM_RAM(0x250)
+
+#define NETXEN_NIC_REG(X)  (NIC_CRB_BASE_PORT1+(X))
+
+/**
+ * CrbPortPhanCntrHi/Lo is used to pass the address of HostPhantomIndex address
+ * which can be read by the Phantom host to get producer/consumer indexes from
+ * Phantom/Casper. If it is not HOST_SHARED_MEMORY, then the following
+ * registers will be used for the addresses of the ring's shared memory
+ * on the Phantom.
+ **/
+
+#define CRB_PHAN_CNTRL_LO_OFFSET   NETXEN_NIC_REG(0x00)
+#define CRB_PHAN_CNTRL_HI_OFFSET   NETXEN_NIC_REG(0x04)
+
+/* point to the indexes */
+#define CRB_CMD_PRODUCER_OFFSETNETXEN_NIC_REG(0x08)
+#define CRB_CMD_CONSUMER_OFFSETNETXEN_NIC_REG(0x0c)
+
+/* address of command descriptors in the host memory */
+#define CRB_HOST_CMD_ADDR_HI   NETXEN_NIC_REG(0x30)
+#define CRB_HOST_CMD_ADDR_LO   NETXEN_NIC_REG(0x34)
+
+/* The following 4 CRB registers are for doing performance coal */
+#define CRB_CMD_INTR_LOOP  NETXEN_NIC_REG(0x38)
+#define CRB_CMD_DMA_LOOP   NETXEN_NIC_REG(0x3c)
+#define CRB_RCV_INTR_LOOP  NETXEN_NIC_REG(0x40)
+#define CRB_RCV_DMA_LOOP   NETXEN_NIC_REG(0x44)
+
+/* Needed by the host to find out the state of Phantom's initialization */
+#define CRB_ENABLE_TX_INTR NETXEN_NIC_REG(0x4c)
+#define CRB_CMDPEG_STATE   NETXEN_NIC_REG(0x50)
+#define CRB_CMDPEG_CMDRING NETXEN_NIC_REG(0x54)
+
+/* Interrupt coalescing parameters */
+#define CRB_GLOBAL_INT_COALNETXEN_NIC_REG(0x80)
+#define CRB_INT_COAL_MODE  NETXEN_NIC_REG(0x84)
+#define CRB_MAX_RCV_BUFS   NETXEN_NIC_REG(0x88)
+#define CRB_TX_INT_THRESHOLD   NETXEN_NIC_REG(0x8c)
+#define CRB_RX_PKT_TIMER   NETXEN_NIC_REG(0x90)
+#define CRB_TX_PKT_TIMER   NETXEN_NIC_REG(0x94)
+#define CRB_RX_PKT_CNT NETXEN_NIC_REG(0x98)
+#define CRB_RX_TMR_CNT NETXEN_NIC_REG(0x9c)
+
+/* Register for communicating XG link status */
+#define CRB_XG_STATE   NETXEN_NIC_REG(0xa0)
+
+/* Debug registers for controlling NIC pkt gen agent */
+#define CRB_AGENT_GO   NETXEN_NIC_REG(0xb0)
+#define CRB_AGENT_TX_SIZE  NETXEN_NIC_REG(0xb4)
+#define CRB_AGENT_TX_TYPE  NETXEN_NIC_REG(0xb8)
+#define CRB_AGENT_TX_ADDR  NETXEN_NIC_REG(0xbc)
+#define CRB_AGENT_TX_MSS   NETXEN_NIC_REG(0xc0)
+
+/* Debug registers for observing NIC performance */
+#define CRB_TX_STATE   NETXEN_NIC_REG(0xd0)
+#define CRB_TX_COUNT   NETXEN_NIC_REG(0xd4)
+#define CRB_RX_STATE   NETXEN_NIC_REG(0xd8)
+
+/* CRB registers per Rcv Descriptor ring */
+struct netxen_rcv_desc_crb {
+   u32 crb_rcv_producer_offset __attribute__ ((aligned(512)));
+   u32 crb_rcv_consumer_offset;
+   u32 crb_globalrcv_ring;
+};
+
+/*
+ * CRB registers used by the receive peg logic. One instance of these
+ * needs to be instantiated per instance of the receive peg.
+ */
+
+struct netxen_recv_crb {
+   struct netxen_rcv_desc_cr

[PATCH 2.6.18-rc7 6/9] NetXen: Main header file

2006-09-15 Thread Amit S. Kale

diff -Narup -X linux-2.6.18-rc7.orig/Documentation/dontdiff 
linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic.h 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic.h
--- linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic.h   1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic.h2006-09-15 
10:51:59.0 -0700
@@ -0,0 +1,913 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#ifndef _NETXEN_NIC_H_
+#define _NETXEN_NIC_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "netxen_nic_hw.h"
+
+#define NETXEN_NIC_BUILD_NO "232"
+#define _NETXEN_NIC_LINUX_MAJOR 2
+#define _NETXEN_NIC_LINUX_MINOR 3
+#define _NETXEN_NIC_LINUX_SUBVERSION 57
+#define NETXEN_NIC_LINUX_VERSIONID  "2.3.57"
+#define NETXEN_NIC_FW_VERSIONID "2.3.57"
+
+#define RCV_DESC_RINGSIZE  \
+   (sizeof(struct rcv_desc_t) * adapter->max_rx_desc_count)
+#define STATUS_DESC_RINGSIZE   \
+   (sizeof(struct status_desc_t)* adapter->max_rx_desc_count)
+#define TX_RINGSIZE\
+   (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count)
+#define RCV_BUFFSIZE   \
+   (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count)
+#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) \
+   ((adapter)->ahw.pci_base + (reg) \
+   - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)
+
+#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)
+#define NETXEN_ROM_ROUNDUP 0x8000ULL
+
+/*
+ * Maximum number of ring contexts
+ */
+#define MAX_RING_CTX 1
+
+/* Opcodes to be used with the commands */
+enum {
+   TX_ETHER_PKT = 0x01,
+/* The following opcodes are for IP checksum   */
+   TX_TCP_PKT,
+   TX_UDP_PKT,
+   TX_IP_PKT,
+   TX_TCP_LSO,
+   TX_IPSEC,
+   TX_IPSEC_CMD
+};
+
+/* The following opcodes are for internal consumption. */
+#define NETXEN_CONTROL_OP  0x10
+#define PEGNET_REQUEST 0x11
+
+#defineMAX_NUM_CARDS   4
+
+#define MAX_BUFFERS_PER_CMD32
+
+/*
+ * 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 0x
+#define PHAN_INITIALIZE_COMPLETE   0xff01
+
+/* Host writes the following to notify that it has done the init-handshake */
+#define PHAN_INITIALIZE_ACK0xf00f
+
+#define NUM_RCV_DESC_RINGS 2   /* No of Rcv Descriptor contexts */
+
+/* descriptor types */
+#define RCV_DESC_NORMAL0x01
+#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_DESCRIPTORS1024
+#define MAX_RCV_DESCRIPTORS32768
+#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 +

[PATCH 2.6.18-rc7 8/9] NetXen: Header file and ioctl header file

2006-09-15 Thread Amit S. Kale

diff -Narup -X linux-2.6.18-rc7.orig/Documentation/dontdiff 
linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_hdr.h 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_hdr.h
--- linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_hdr.h   1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_hdr.h2006-09-15 
10:51:59.0 -0700
@@ -0,0 +1,618 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#ifndef __NETXEN_NIC_HDR_H_
+#define __NETXEN_NIC_HDR_H_
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include   /* for memset */
+
+/*
+ * The basic unit of access when reading/writing control registers.
+ */
+
+typedef __le32 netxen_crbword_t;   /* single word in CRB space */
+
+enum {
+   NETXEN_HW_H0_CH_HUB_ADR = 0x05,
+   NETXEN_HW_H1_CH_HUB_ADR = 0x0E,
+   NETXEN_HW_H2_CH_HUB_ADR = 0x03,
+   NETXEN_HW_H3_CH_HUB_ADR = 0x01,
+   NETXEN_HW_H4_CH_HUB_ADR = 0x06,
+   NETXEN_HW_H5_CH_HUB_ADR = 0x07,
+   NETXEN_HW_H6_CH_HUB_ADR = 0x08
+};
+
+/*  Hub 0 */
+enum {
+   NETXEN_HW_MN_CRB_AGT_ADR = 0x15,
+   NETXEN_HW_MS_CRB_AGT_ADR = 0x25
+};
+
+/*  Hub 1 */
+enum {
+   NETXEN_HW_PS_CRB_AGT_ADR = 0x73,
+   NETXEN_HW_SS_CRB_AGT_ADR = 0x20,
+   NETXEN_HW_RPMX3_CRB_AGT_ADR = 0x0b,
+   NETXEN_HW_QMS_CRB_AGT_ADR = 0x00,
+   NETXEN_HW_SQGS0_CRB_AGT_ADR = 0x01,
+   NETXEN_HW_SQGS1_CRB_AGT_ADR = 0x02,
+   NETXEN_HW_SQGS2_CRB_AGT_ADR = 0x03,
+   NETXEN_HW_SQGS3_CRB_AGT_ADR = 0x04,
+   NETXEN_HW_C2C0_CRB_AGT_ADR = 0x58,
+   NETXEN_HW_C2C1_CRB_AGT_ADR = 0x59,
+   NETXEN_HW_C2C2_CRB_AGT_ADR = 0x5a,
+   NETXEN_HW_RPMX2_CRB_AGT_ADR = 0x0a,
+   NETXEN_HW_RPMX4_CRB_AGT_ADR = 0x0c,
+   NETXEN_HW_RPMX7_CRB_AGT_ADR = 0x0f,
+   NETXEN_HW_RPMX9_CRB_AGT_ADR = 0x12,
+   NETXEN_HW_SMB_CRB_AGT_ADR = 0x18
+};
+
+/*  Hub 2 */
+enum {
+   NETXEN_HW_NIU_CRB_AGT_ADR = 0x31,
+   NETXEN_HW_I2C0_CRB_AGT_ADR = 0x19,
+   NETXEN_HW_I2C1_CRB_AGT_ADR = 0x29,
+
+   NETXEN_HW_SN_CRB_AGT_ADR = 0x10,
+   NETXEN_HW_I2Q_CRB_AGT_ADR = 0x20,
+   NETXEN_HW_LPC_CRB_AGT_ADR = 0x22,
+   NETXEN_HW_ROMUSB_CRB_AGT_ADR = 0x21,
+   NETXEN_HW_QM_CRB_AGT_ADR = 0x66,
+   NETXEN_HW_SQG0_CRB_AGT_ADR = 0x60,
+   NETXEN_HW_SQG1_CRB_AGT_ADR = 0x61,
+   NETXEN_HW_SQG2_CRB_AGT_ADR = 0x62,
+   NETXEN_HW_SQG3_CRB_AGT_ADR = 0x63,
+   NETXEN_HW_RPMX1_CRB_AGT_ADR = 0x09,
+   NETXEN_HW_RPMX5_CRB_AGT_ADR = 0x0d,
+   NETXEN_HW_RPMX6_CRB_AGT_ADR = 0x0e,
+   NETXEN_HW_RPMX8_CRB_AGT_ADR = 0x11
+};
+
+/*  Hub 3 */
+enum {
+   NETXEN_HW_PH_CRB_AGT_ADR = 0x1A,
+   NETXEN_HW_SRE_CRB_AGT_ADR = 0x50,
+   NETXEN_HW_EG_CRB_AGT_ADR = 0x51,
+   NETXEN_HW_RPMX0_CRB_AGT_ADR = 0x08
+};
+
+/*  Hub 4 */
+enum {
+   NETXEN_HW_PEGN0_CRB_AGT_ADR = 0x40,
+   NETXEN_HW_PEGN1_CRB_AGT_ADR,
+   NETXEN_HW_PEGN2_CRB_AGT_ADR,
+   NETXEN_HW_PEGN3_CRB_AGT_ADR,
+   NETXEN_HW_PEGNI_CRB_AGT_ADR,
+   NETXEN_HW_PEGND_CRB_AGT_ADR,
+   NETXEN_HW_PEGNC_CRB_AGT_ADR,
+   NETXEN_HW_PEGR0_CRB_AGT_ADR,
+   NETXEN_HW_PEGR1_CRB_AGT_ADR,
+   NETXEN_HW_PEGR2_CRB_AGT_ADR,
+   NETXEN_HW_PEGR3_CRB_AGT_ADR
+};
+
+/*  Hub 5 */
+enum {
+   NETXEN_HW_PEGS0_CRB_AGT_ADR = 0x40,
+   NETXEN_HW_PEGS1_CRB_AGT_ADR,
+   NETXEN_HW_PEGS2_CRB_AGT_ADR,
+   NETXEN_HW_PEGS3_CRB_AGT_ADR,
+   NETXEN_HW_PEGSI_CRB_AGT_ADR,
+   NETXEN_HW_PEGSD_CRB_AGT_ADR,
+   NETXEN_HW_PEGSC_CRB_AGT_ADR
+};
+
+/*  Hub 6 */
+enum {
+   NETXEN_HW_CAS0_CRB_AGT_ADR = 0x46,
+   NETXEN_HW_CAS1_CRB_AGT_ADR = 0x47,
+   NETXEN_HW_CAS2_CRB_AGT_ADR = 0x48,
+   NETXEN_HW_CAS3_CRB_AGT_ADR = 0x49,
+   NETXEN_HW_NCM_CRB_AGT_ADR = 0x16,
+   NETXEN_HW_TMR_CRB_AGT_ADR = 0x17,
+   NETXEN_HW_XDMA_CRB_AGT_ADR = 0x05,
+   NETXEN_HW_OCM0_CRB_AGT_ADR = 0x06,
+   NETXEN_HW_OCM1_CR

[PATCH 2.6.18-rc7 7/9] NetXen: hw access routines header file

2006-09-15 Thread Amit S. Kale

diff -Narup -X linux-2.6.18-rc7.orig/Documentation/dontdiff 
linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_hw.h 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_hw.h
--- linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_hw.h1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_hw.h 2006-09-15 
10:51:59.0 -0700
@@ -0,0 +1,467 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * Structures, enums, and macros for the MAC
+ *
+ */
+
+#ifndef __NETXEN_NIC_HW_H_
+#define __NETXEN_NIC_HW_H_
+
+#include "netxen_nic_hdr.h"
+
+/* Hardware memory size of 128 meg */
+#define NETXEN_MEMADDR_MAX (128 * 1024 * 1024)
+
+#ifndef readq
+static inline u64 readq(void __iomem * addr)
+{
+   return readl(addr) | (((u64) readl(addr + 4)) << 32LL);
+}
+#endif
+
+#ifndef writeq
+static inline void writeq(u64 val, void __iomem * addr)
+{
+   writel(((u32) (val)), (addr));
+   writel(((u32) (val >> 32)), (addr + 4));
+}
+#endif
+
+static inline void netxen_nic_hw_block_write64(u64 __iomem * data_ptr,
+  u64 __iomem * addr,
+  int num_words)
+{
+   int num;
+   for (num = 0; num < num_words; num++) {
+   writeq(readq((void __iomem *)data_ptr), addr);
+   addr++;
+   data_ptr++;
+   }
+}
+
+static inline void netxen_nic_hw_block_read64(u64 __iomem * data_ptr,
+ u64 __iomem * addr, int num_words)
+{
+   int num;
+   for (num = 0; num < num_words; num++) {
+   writeq(readq((void __iomem *)addr), data_ptr);
+   addr++;
+   data_ptr++;
+   }
+
+}
+
+struct netxen_adapter;
+
+#define NETXEN_PCI_MAPSIZE_BYTES  (NETXEN_PCI_MAPSIZE << 20)
+
+#define NETXEN_NIC_LOCKED_READ_REG(X, Y)   \
+   addr = (adapter->ahw.pci_base + X); \
+   *(u32 *)Y = readl((void __iomem*) addr);
+
+struct netxen_port;
+void netxen_nic_set_link_parameters(struct netxen_port *port);
+void netxen_nic_flash_print(struct netxen_adapter *adapter);
+int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off,
+  void *data, int len);
+void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
+unsigned long off, int data);
+int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off,
+ void *data, int len);
+
+typedef u8 netxen_ethernet_macaddr_t[6];
+
+/* Nibble or Byte mode for phy interface (GbE mode only) */
+typedef enum {
+   NETXEN_NIU_10_100_MB = 0,
+   NETXEN_NIU_1000_MB
+} netxen_niu_gbe_ifmode_t;
+
+#define _netxen_crb_get_bit(var, bit)  ((var >> bit) & 0x1)
+
+/*
+ * NIU GB MAC Config Register 0 (applies to GB0, GB1, GB2, GB3)
+ *
+ * Bit 0 : enable_tx => 1:enable frame xmit, 0:disable
+ * Bit 1 : tx_synced => R/O: xmit enable synched to xmit stream
+ * Bit 2 : enable_rx => 1:enable frame recv, 0:disable
+ * Bit 3 : rx_synced => R/O: recv enable synched to recv stream
+ * Bit 4 : tx_flowctl => 1:enable pause frame generation, 0:disable
+ * Bit 5 : rx_flowctl => 1:act on recv'd pause frames, 0:ignore
+ * Bit 8 : loopback => 1:loop MAC xmits to MAC recvs, 0:normal
+ * Bit 16: tx_reset_pb => 1:reset frame xmit protocol blk, 0:no-op
+ * Bit 17: rx_reset_pb => 1:reset frame recv protocol blk, 0:no-op
+ * Bit 18: tx_reset_mac => 1:reset data/ctl multiplexer blk, 0:no-op
+ * Bit 19: rx_reset_mac => 1:reset ctl frames & timers blk, 0:no-op
+ * Bit 31: soft_reset => 1:reset the MAC and the SERDES, 0:no-op
+ */
+
+#define netxen_gb_enable_tx(config_word)   \
+   set_bit(0, (unsigned long*)(&config_word))
+#define netxen_gb_enable_rx(config_word)   \
+   set_bit(2, (unsigned long*)(&config_word))
+#define netxen_gb_tx_flowctl(config_word)  \
+   set_bit(4, (unsigned long*)(&con

[PATCH 2.6.18-rc7 5/9] NetXen: ethtool interface

2006-09-15 Thread Amit S. Kale

diff -Narup -X linux-2.6.18-rc7.orig/Documentation/dontdiff 
linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_ethtool.c 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_ethtool.c
--- linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_ethtool.c   
1969-12-31 16:00:00.0 -0800
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_ethtool.c2006-09-15 
10:51:59.0 -0700
@@ -0,0 +1,715 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * ethtool support for netxen nic
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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(__le32))
+#define NETXEN_MAX_EEPROM_LEN   1024
+
+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 & NETXEN_ROM_ROUNDUP)) {
+   n &= ~NETXEN_ROM_ROUNDUP;
+   if (n < NETXEN_MAX_EEPROM_LEN)
+   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);
+   struct netxen_adapter *adapter = port->adapter;
+   uint32_t fw_major = 0;
+   uint32_t fw_minor = 0;
+   uint32_t fw_build = 0;
+
+   strncpy(drvinfo->driver, "NetXen", 32);
+   strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32);
+   fw_major = readl(NETXEN_CRB_NORMALIZE(adapter,
+ NETXEN_FW_VERSION_MAJOR));
+   fw_minor = readl(NETXEN_CRB_NORMALIZE(adapter,
+ NETXEN_FW_VERSION_MINOR));
+   fw_build = readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_FW_VERSION_SUB));
+   sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_mi

[PATCH 2.6.18-rc7 4/9] NetXen: intr routines and niu handling

2006-09-15 Thread Amit S. Kale

diff -Narup -X linux-2.6.18-rc7.orig/Documentation/dontdiff 
linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_isr.c 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_isr.c
--- linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_isr.c   1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_isr.c2006-09-15 
10:51:59.0 -0700
@@ -0,0 +1,221 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#include 
+#include 
+
+#include "netxen_nic.h"
+#include "netxen_nic_hw.h"
+#include "netxen_nic_phan_reg.h"
+
+/*
+ * netxen_nic_get_stats - Get System Network Statistics
+ * @netdev: network interface device structure
+ */
+struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct net_device_stats *stats = &port->net_stats;
+
+   memset(stats, 0, sizeof(*stats));
+
+   /* total packets received   */
+   stats->rx_packets = port->stats.no_rcv;
+   /* total packets transmitted*/
+   stats->tx_packets = port->stats.xmitedframes + port->stats.xmitfinished;
+   /* total bytes received */
+   stats->rx_bytes = port->stats.rxbytes;
+   /* total bytes transmitted  */
+   stats->tx_bytes = port->stats.txbytes;
+   /* bad packets received */
+   stats->rx_errors = port->stats.rcvdbadskb;
+   /* packet transmit problems */
+   stats->tx_errors = port->stats.nocmddescriptor;
+   /* no space in linux buffers*/
+   stats->rx_dropped = port->stats.updropped;
+   /* no space available in linux  */
+   stats->tx_dropped = port->stats.txdropped;
+
+   return stats;
+}
+
+void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno,
+u32 link)
+{
+   struct netxen_port *pport = adapter->port[portno];
+   struct net_device *netdev = pport->netdev;
+
+   if (link)
+   netif_carrier_on(netdev);
+   else
+   netif_carrier_off(netdev);
+}
+
+void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno,
+   u32 enable)
+{
+   __le32 int_src;
+   struct netxen_port *port;
+
+   /*  This should clear the interrupt source */
+   if (adapter->ops->phy_read)
+   adapter->ops->phy_read(adapter, portno,
+  NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
+  &int_src);
+   if (int_src == 0) {
+   DPRINTK(INFO, "No phy interrupts for port #%d\n", portno);
+   return;
+   }
+   if (adapter->ops->disable_phy_interrupts)
+   adapter->ops->disable_phy_interrupts(adapter, portno);
+
+   port = adapter->port[portno];
+
+   if (netxen_get_phy_int_jabber(int_src))
+   DPRINTK(INFO, "NetXen: %s Jabber interrupt \n",
+   port->netdev->name);
+
+   if (netxen_get_phy_int_polarity_changed(int_src))
+   DPRINTK(INFO, "NetXen: %s POLARITY CHANGED int \n",
+   port->netdev->name);
+
+   if (netxen_get_phy_int_energy_detect(int_src))
+   DPRINTK(INFO, "NetXen: %s ENERGY DETECT INT \n",
+   port->netdev->name);
+
+   if (netxen_get_phy_int_downshift(int_src))
+   DPRINTK(INFO, "NetXen: %s DOWNSHIFT INT \n",
+   port->netdev->name);
+   /* write it down later.. */
+   if ((netxen_get_phy_int_speed_changed(int_src))
+   || (netxen_get_phy_int_link_status_changed(int_src))) {
+   __le32 status;
+
+   DPRINTK(INFO, "NetXen: %s SPEED CHANGED OR"
+   " LINK STATUS CHANGED \n", port->netdev->name);
+
+   if (adapter->ops->phy_read
+   && adapter->ops->phy_read(adapter, portno,
+ 
NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
+ 

[PATCH 2.6.18-rc7 3/9] NetXen: hw initilization routines

2006-09-15 Thread Amit S. Kale

diff -Narup -X linux-2.6.18-rc7.orig/Documentation/dontdiff 
linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_init.c 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_init.c
--- linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_init.c  1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_init.c   2006-09-15 
10:51:59.0 -0700
@@ -0,0 +1,1143 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * Source file for NIC routines to initialize the Phantom Hardware
+ *
+ */
+
+#include 
+#include 
+#include "netxen_nic.h"
+#include "netxen_nic_hw.h"
+#include "netxen_nic_ioctl.h"
+#include "netxen_nic_phan_reg.h"
+
+struct crb_addr_pair {
+   long addr;
+   long data;
+};
+
+#define NETXEN_MAX_CRB_XFORM 60
+static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM];
+#define NETXEN_ADDR_ERROR ((unsigned long ) 0x )
+
+#define crb_addr_transform(name) \
+   crb_addr_xform[NETXEN_HW_PX_MAP_CRB_##name] = \
+   NETXEN_HW_CRB_HUB_AGT_ADR_##name << 20
+
+static inline void
+netxen_nic_locked_write_reg(struct netxen_adapter *adapter,
+   unsigned long off, int *data)
+{
+   void __iomem *addr = (adapter->ahw.pci_base + off);
+   writel(*data, addr);
+}
+
+static void crb_addr_transform_setup(void)
+{
+   crb_addr_transform(XDMA);
+   crb_addr_transform(TIMR);
+   crb_addr_transform(SRE);
+   crb_addr_transform(SQN3);
+   crb_addr_transform(SQN2);
+   crb_addr_transform(SQN1);
+   crb_addr_transform(SQN0);
+   crb_addr_transform(SQS3);
+   crb_addr_transform(SQS2);
+   crb_addr_transform(SQS1);
+   crb_addr_transform(SQS0);
+   crb_addr_transform(RPMX7);
+   crb_addr_transform(RPMX6);
+   crb_addr_transform(RPMX5);
+   crb_addr_transform(RPMX4);
+   crb_addr_transform(RPMX3);
+   crb_addr_transform(RPMX2);
+   crb_addr_transform(RPMX1);
+   crb_addr_transform(RPMX0);
+   crb_addr_transform(ROMUSB);
+   crb_addr_transform(SN);
+   crb_addr_transform(QMN);
+   crb_addr_transform(QMS);
+   crb_addr_transform(PGNI);
+   crb_addr_transform(PGND);
+   crb_addr_transform(PGN3);
+   crb_addr_transform(PGN2);
+   crb_addr_transform(PGN1);
+   crb_addr_transform(PGN0);
+   crb_addr_transform(PGSI);
+   crb_addr_transform(PGSD);
+   crb_addr_transform(PGS3);
+   crb_addr_transform(PGS2);
+   crb_addr_transform(PGS1);
+   crb_addr_transform(PGS0);
+   crb_addr_transform(PS);
+   crb_addr_transform(PH);
+   crb_addr_transform(NIU);
+   crb_addr_transform(I2Q);
+   crb_addr_transform(EG);
+   crb_addr_transform(MN);
+   crb_addr_transform(MS);
+   crb_addr_transform(CAS2);
+   crb_addr_transform(CAS1);
+   crb_addr_transform(CAS0);
+   crb_addr_transform(CAM);
+   crb_addr_transform(C2C1);
+   crb_addr_transform(C2C0);
+}
+
+int netxen_init_firmware(struct netxen_adapter *adapter)
+{
+   u32 state = 0, loops = 0, err = 0;
+
+   /* Window 1 call */
+   state = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
+
+   if (state == PHAN_INITIALIZE_ACK)
+   return 0;
+
+   while (state != PHAN_INITIALIZE_COMPLETE && loops < 2000) {
+   udelay(100);
+   /* Window 1 call */
+   state = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
+
+   loops++;
+   }
+   if (loops >= 2000) {
+   printk(KERN_ERR "Cmd Peg initialization not complete:%x.\n",
+  state);
+   err = -EIO;
+   return err;
+   }
+   /* Window 1 call */
+   writel(PHAN_INITIALIZE_ACK,
+  NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
+
+   return err;
+}
+
+void netxen_initialize_adapter_sw(struct netxen_adapter *adapter)
+{
+   int ctxid, ring;
+   u32 i;
+   u32 num_rx_bufs = 0;
+   struct n

[PATCH 2.6.18-rc7 1/9] NetXen: Makefile and driver main file

2006-09-15 Thread Amit S. Kale

diff -Narup -X linux-2.6.18-rc7.orig/Documentation/dontdiff 
linux-2.6.18-rc7.orig/MAINTAINERS linux-2.6.18-rc7/MAINTAINERS
--- linux-2.6.18-rc7.orig/MAINTAINERS   2006-09-15 09:27:56.0 -0700
+++ linux-2.6.18-rc7/MAINTAINERS2006-09-15 09:32:05.0 -0700
@@ -2060,6 +2060,13 @@ L:   netdev@vger.kernel.org
 T: git kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6.git
 S: Maintained

+NETXEN (1/10) GbE SUPPORT
+P: Amit S. Kale
+M: [EMAIL PROTECTED]
+L: netdev@vger.kernel.org
+W: http://www.netxen.com
+S: Supported
+
 IPVS
 P: Wensong Zhang
 M: [EMAIL PROTECTED]
diff -Narup -X linux-2.6.18-rc7.orig/Documentation/dontdiff 
linux-2.6.18-rc7.orig/drivers/net/Kconfig linux-2.6.18-rc7/drivers/net/Kconfig
--- linux-2.6.18-rc7.orig/drivers/net/Kconfig   2006-09-15 09:27:55.0 
-0700
+++ linux-2.6.18-rc7/drivers/net/Kconfig2006-09-15 09:33:43.0 
-0700
@@ -2399,6 +2399,11 @@ config MYRI10GE
  .  The module
  will be called myri10ge.

+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 -Narup -X linux-2.6.18-rc7.orig/Documentation/dontdiff 
linux-2.6.18-rc7.orig/drivers/net/Makefile linux-2.6.18-rc7/drivers/net/Makefile
--- linux-2.6.18-rc7.orig/drivers/net/Makefile  2006-09-15 09:27:55.0 
-0700
+++ linux-2.6.18-rc7/drivers/net/Makefile   2006-09-15 10:51:59.0 
-0700
@@ -219,3 +219,4 @@ obj-$(CONFIG_NETCONSOLE) += netconsole.o

 obj-$(CONFIG_FS_ENET) += fs_enet/

+obj-$(CONFIG_NETXEN_NIC) += netxen/
diff -Narup -X linux-2.6.18-rc7.orig/Documentation/dontdiff 
linux-2.6.18-rc7.orig/drivers/net/netxen/Makefile 
linux-2.6.18-rc7/drivers/net/netxen/Makefile
--- linux-2.6.18-rc7.orig/drivers/net/netxen/Makefile   1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18-rc7/drivers/net/netxen/Makefile2006-09-15 
10:51:59.0 -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:

+#[EMAIL PROTECTED]
+# 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 -Narup -X linux-2.6.18-rc7.orig/Documentation/dontdiff 
linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_main.c 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_main.c
--- linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_main.c  1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_main.c   2006-09-15 
10:51:59.0 -0700
@@ -0,0 +1,1116 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ *  Main source file for NetXen NIC Driver on Linux
+ *
+ */
+
+#include "netxen_nic_hw.h"
+
+#include "netxen_nic.h"
+#define DEFINE_GLOBAL_RECV_CR

[PATCH 2.6.18-rc7 2/9] NetXen: Hardware access routines

2006-09-15 Thread Amit S. Kale

diff -Narup -X linux-2.6.18-rc7.orig/Documentation/dontdiff 
linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_hw.c 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_hw.c
--- linux-2.6.18-rc7.orig/drivers/net/netxen/netxen_nic_hw.c1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_hw.c 2006-09-15 
10:51:59.0 -0700
@@ -0,0 +1,947 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * Source file for NIC routines to access the Phantom hardware
+ *
+ */
+
+#include "netxen_nic.h"
+#include "netxen_nic_hw.h"
+#include "netxen_nic_phan_reg.h"
+
+/*  PCI Windowing for DDR regions.  */
+
+#define ADDR_IN_RANGE(addr, low, high) \
+   (((addr) <= (high)) && ((addr) >= (low)))
+
+#define NETXEN_FLASH_BASE  (BOOTLD_START)
+#define NETXEN_PHANTOM_MEM_BASE(NETXEN_FLASH_BASE)
+#define NETXEN_MAX_MTU 8000
+#define NETXEN_MIN_MTU  64
+#define NETXEN_MTU_MASK0x
+#define NETXEN_ETH_FCS_SIZE 4
+#define NETXEN_ENET_HEADER_SIZE 14
+#define NETXEN_WINDOW_ONE 0x200/* CRB Window: bit 25 of CRB address */
+#define NETXEN_FIRMWARE_LEN((16 * 1024) / 4)
+#define NETXEN_NIU_HDRSIZE (0x1 << 6)
+#define NETXEN_NIU_TLRSIZE (0x1 << 5)
+
+unsigned long netxen_nic_pci_set_window(void __iomem * pci_base,
+   unsigned long long addr);
+void netxen_free_hw_resources(struct netxen_adapter *adapter);
+
+int netxen_nic_set_mac(struct net_device *netdev, void *p)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct netxen_adapter *adapter = port->adapter;
+   struct sockaddr *addr = p;
+
+   if (netif_running(netdev))
+   return -EBUSY;
+
+   if (!is_valid_ether_addr(addr->sa_data))
+   return -EADDRNOTAVAIL;
+
+   DPRINTK(INFO, "valid ether addr\n");
+   memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
+
+   if (adapter->ops->macaddr_set)
+   adapter->ops->macaddr_set(port, addr->sa_data);
+
+   return 0;
+}
+
+/**
+ * netxen_nic_set_multi - Multicast
+ **/
+void netxen_nic_set_multi(struct net_device *netdev)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct netxen_adapter *adapter = port->adapter;
+   struct dev_mc_list *mc_ptr;
+   __le32 netxen_mac_addr_cntl_data = 0;
+
+   mc_ptr = netdev->mc_list;
+   if (netdev->flags & IFF_PROMISC) {
+   if (adapter->ops->set_promisc_mode)
+   adapter->ops->set_promisc_mode(adapter,
+  port->portnum,
+  
NETXEN_NIU_PROMISCOUS_MODE);
+   } else {
+   if (adapter->ops->unset_promisc_mode)
+   adapter->ops->unset_promisc_mode(adapter,
+port->portnum,
+
NETXEN_NIU_NON_PROMISCOUS_MODE);
+   }
+   if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
+   netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x03);
+   netxen_nic_mcr_set_id_pool0(netxen_mac_addr_cntl_data, 0x00);
+   netxen_nic_mcr_set_id_pool1(netxen_mac_addr_cntl_data, 0x00);
+   netxen_nic_mcr_set_id_pool2(netxen_mac_addr_cntl_data, 0x00);
+   netxen_nic_mcr_set_id_pool3(netxen_mac_addr_cntl_data, 0x00);
+   netxen_nic_mcr_set_enable_xtnd0(netxen_mac_addr_cntl_data);
+   netxen_nic_mcr_set_enable_xtnd1(netxen_mac_addr_cntl_data);
+   netxen_nic_mcr_set_enable_xtnd2(netxen_mac_addr_cntl_data);
+   netxen_nic_mcr_set_enable_xtnd3(netxen_mac_addr_cntl_data);
+   } else {
+   netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x00);
+   netxen_nic_mcr_set_id_pool0(netxen_mac_addr_cntl_data, 0x00);
+   netxen_nic_mc

[PATCH 2.6.18-rc7 0/9] NetXen: 1G/10G Ethernet Driver

2006-09-15 Thread Amit S. Kale

Hi All,

Thank you Jeff.
We have incorporated feedbacks which received. I'll be sending updated 
patchset in subsequent emails.


-Amit

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

 MAINTAINERS  |7
 drivers/net/Kconfig  |5
 drivers/net/Makefile |1
 drivers/net/netxen/Makefile  |   35
 drivers/net/netxen/netxen_nic.h  |  913 
 drivers/net/netxen/netxen_nic_ethtool.c  |  715 +++
 drivers/net/netxen/netxen_nic_hdr.h  |  618 
 drivers/net/netxen/netxen_nic_hw.c   |  947 +
 drivers/net/netxen/netxen_nic_hw.h   |  467 
 drivers/net/netxen/netxen_nic_init.c | 1143 +++
 drivers/net/netxen/netxen_nic_ioctl.h|   75 ++
 drivers/net/netxen/netxen_nic_isr.c  |  221 +
 drivers/net/netxen/netxen_nic_main.c | 1116 ++
 drivers/net/netxen/netxen_nic_niu.c  |  800 +
 drivers/net/netxen/netxen_nic_phan_reg.h |  195 +
 15 files changed, 7258 insertions(+)
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2.6.17 9/9] NetXen: CRB reg definitions

2006-08-31 Thread Amit S. Kale

diff -Narup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/netxen/netxen_nic_phan_reg.h 
linux-2.6.17/drivers/net/netxen/netxen_nic_phan_reg.h
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_phan_reg.h  1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_phan_reg.h   2006-08-31 
06:17:22.0 -0700
@@ -0,0 +1,195 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#ifndef __NIC_PHAN_REG_H_
+#define __NIC_PHAN_REG_H_
+
+/** 
+ * CRB Registers or queue message done only at initialization time

+ **/
+
+/**
+ * The following 2 are the base adresses for the CRB registers and their
+ * offsets will be added to get addresses for the index addresses...
+ **/
+#define NIC_CRB_BASE_PORT1 NETXEN_CAM_RAM(0x200)
+#define NIC_CRB_BASE_PORT2 NETXEN_CAM_RAM(0x250)
+
+#define NETXEN_NIC_REG(X)  (NIC_CRB_BASE_PORT1+(X))
+
+/**
+ * CrbPortPhanCntrHi/Lo is used to pass the address of HostPhantomIndex address
+ * which can be read by the Phantom host to get producer/consumer indexes from
+ * Phantom/Casper. If it is not HOST_SHARED_MEMORY, then the following
+ * registers will be used for the addresses of the ring's shared memory
+ * on the Phantom.
+ **/
+
+#define CRB_PHAN_CNTRL_LO_OFFSET   NETXEN_NIC_REG(0x00)
+#define CRB_PHAN_CNTRL_HI_OFFSET   NETXEN_NIC_REG(0x04)
+
+/* point to the indexes */
+#define CRB_CMD_PRODUCER_OFFSETNETXEN_NIC_REG(0x08)
+#define CRB_CMD_CONSUMER_OFFSETNETXEN_NIC_REG(0x0c)
+
+/* address of command descriptors in the host memory */
+#define CRB_HOST_CMD_ADDR_HI   NETXEN_NIC_REG(0x30)
+#define CRB_HOST_CMD_ADDR_LO   NETXEN_NIC_REG(0x34)
+
+/* The following 4 CRB registers are for doing performance coal */
+#define CRB_CMD_INTR_LOOP  NETXEN_NIC_REG(0x38)
+#define CRB_CMD_DMA_LOOP   NETXEN_NIC_REG(0x3c)
+#define CRB_RCV_INTR_LOOP  NETXEN_NIC_REG(0x40)
+#define CRB_RCV_DMA_LOOP   NETXEN_NIC_REG(0x44)
+
+/* Needed by the host to find out the state of Phantom's initialization */
+#define CRB_ENABLE_TX_INTR NETXEN_NIC_REG(0x4c)
+#define CRB_CMDPEG_STATE   NETXEN_NIC_REG(0x50)
+#define CRB_CMDPEG_CMDRING NETXEN_NIC_REG(0x54)
+
+/* Interrupt coalescing parameters */
+#define CRB_GLOBAL_INT_COALNETXEN_NIC_REG(0x80)
+#define CRB_INT_COAL_MODE  NETXEN_NIC_REG(0x84)
+#define CRB_MAX_RCV_BUFS   NETXEN_NIC_REG(0x88)
+#define CRB_TX_INT_THRESHOLD   NETXEN_NIC_REG(0x8c)
+#define CRB_RX_PKT_TIMER   NETXEN_NIC_REG(0x90)
+#define CRB_TX_PKT_TIMER   NETXEN_NIC_REG(0x94)
+#define CRB_RX_PKT_CNT NETXEN_NIC_REG(0x98)
+#define CRB_RX_TMR_CNT NETXEN_NIC_REG(0x9c)
+
+/* Register for communicating XG link status */
+#define CRB_XG_STATE   NETXEN_NIC_REG(0xa0)
+
+/* Debug registers for controlling NIC pkt gen agent */
+#define CRB_AGENT_GO   NETXEN_NIC_REG(0xb0)
+#define CRB_AGENT_TX_SIZE  NETXEN_NIC_REG(0xb4)
+#define CRB_AGENT_TX_TYPE  NETXEN_NIC_REG(0xb8)
+#define CRB_AGENT_TX_ADDR  NETXEN_NIC_REG(0xbc)
+#define CRB_AGENT_TX_MSS   NETXEN_NIC_REG(0xc0)
+
+/* Debug registers for observing NIC performance */
+#define CRB_TX_STATE   NETXEN_NIC_REG(0xd0)
+#define CRB_TX_COUNT   NETXEN_NIC_REG(0xd4)
+#define CRB_RX_STATE   NETXEN_NIC_REG(0xd8)
+
+/* CRB registers per Rcv Descriptor ring */
+struct netxen_rcv_desc_crb {
+   u32 crb_rcv_producer_offset __attribute__ ((aligned(512)));
+   u32 crb_rcv_consumer_offset;
+   u32 crb_globalrcv_ring;
+};
+
+/*
+ * CRB registers used by the receive peg logic. One instance of these
+ * needs to be instantiated per instance of the receive peg.
+ */
+
+struct netxen_recv_crb {
+   struct netxen_rcv_desc_crb rcv_desc_crb[NUM_R

[PATCH 2.6.17 8/9] NetXen: Header file and ioctl header file

2006-08-31 Thread Amit S. Kale

diff -Narup -X linux-2.6.17.orig/Documentation/dontdiff 
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.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_hdr.h2006-08-31 
06:17:22.0 -0700
@@ -0,0 +1,611 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#ifndef __NETXEN_NIC_HDR_H_
+#define __NETXEN_NIC_HDR_H_
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include   /* for memset */
+
+/*
+ * The basic unit of access when reading/writing control registers.
+ */
+
+typedef __le32 netxen_crbword_t;   /* single word in CRB space */
+
+enum {
+   NETXEN_HW_H0_CH_HUB_ADR = 0x05,
+   NETXEN_HW_H1_CH_HUB_ADR = 0x0E,
+   NETXEN_HW_H2_CH_HUB_ADR = 0x03,
+   NETXEN_HW_H3_CH_HUB_ADR = 0x01,
+   NETXEN_HW_H4_CH_HUB_ADR = 0x06,
+   NETXEN_HW_H5_CH_HUB_ADR = 0x07,
+   NETXEN_HW_H6_CH_HUB_ADR = 0x08
+};
+
+/*  Hub 0 */
+enum {
+   NETXEN_HW_MN_CRB_AGT_ADR = 0x15,
+   NETXEN_HW_MS_CRB_AGT_ADR = 0x25
+};
+
+/*  Hub 1 */
+enum {
+   NETXEN_HW_PS_CRB_AGT_ADR = 0x73,
+   NETXEN_HW_SS_CRB_AGT_ADR = 0x20,
+   NETXEN_HW_RPMX3_CRB_AGT_ADR = 0x0b,
+   NETXEN_HW_QMS_CRB_AGT_ADR = 0x00,
+   NETXEN_HW_SQGS0_CRB_AGT_ADR = 0x01,
+   NETXEN_HW_SQGS1_CRB_AGT_ADR = 0x02,
+   NETXEN_HW_SQGS2_CRB_AGT_ADR = 0x03,
+   NETXEN_HW_SQGS3_CRB_AGT_ADR = 0x04,
+   NETXEN_HW_C2C0_CRB_AGT_ADR = 0x58,
+   NETXEN_HW_C2C1_CRB_AGT_ADR = 0x59,
+   NETXEN_HW_C2C2_CRB_AGT_ADR = 0x5a,
+   NETXEN_HW_RPMX2_CRB_AGT_ADR = 0x0a,
+   NETXEN_HW_RPMX4_CRB_AGT_ADR = 0x0c,
+   NETXEN_HW_RPMX7_CRB_AGT_ADR = 0x0f,
+   NETXEN_HW_RPMX9_CRB_AGT_ADR = 0x12,
+   NETXEN_HW_SMB_CRB_AGT_ADR = 0x18
+};
+
+/*  Hub 2 */
+enum {
+   NETXEN_HW_NIU_CRB_AGT_ADR = 0x31,
+   NETXEN_HW_I2C0_CRB_AGT_ADR = 0x19,
+   NETXEN_HW_I2C1_CRB_AGT_ADR = 0x29,
+
+   NETXEN_HW_SN_CRB_AGT_ADR = 0x10,
+   NETXEN_HW_I2Q_CRB_AGT_ADR = 0x20,
+   NETXEN_HW_LPC_CRB_AGT_ADR = 0x22,
+   NETXEN_HW_ROMUSB_CRB_AGT_ADR = 0x21,
+   NETXEN_HW_QM_CRB_AGT_ADR = 0x66,
+   NETXEN_HW_SQG0_CRB_AGT_ADR = 0x60,
+   NETXEN_HW_SQG1_CRB_AGT_ADR = 0x61,
+   NETXEN_HW_SQG2_CRB_AGT_ADR = 0x62,
+   NETXEN_HW_SQG3_CRB_AGT_ADR = 0x63,
+   NETXEN_HW_RPMX1_CRB_AGT_ADR = 0x09,
+   NETXEN_HW_RPMX5_CRB_AGT_ADR = 0x0d,
+   NETXEN_HW_RPMX6_CRB_AGT_ADR = 0x0e,
+   NETXEN_HW_RPMX8_CRB_AGT_ADR = 0x11
+};
+
+/*  Hub 3 */
+enum {
+   NETXEN_HW_PH_CRB_AGT_ADR = 0x1A,
+   NETXEN_HW_SRE_CRB_AGT_ADR = 0x50,
+   NETXEN_HW_EG_CRB_AGT_ADR = 0x51,
+   NETXEN_HW_RPMX0_CRB_AGT_ADR = 0x08
+};
+
+/*  Hub 4 */
+enum {
+   NETXEN_HW_PEGN0_CRB_AGT_ADR = 0x40,
+   NETXEN_HW_PEGN1_CRB_AGT_ADR,
+   NETXEN_HW_PEGN2_CRB_AGT_ADR,
+   NETXEN_HW_PEGN3_CRB_AGT_ADR,
+   NETXEN_HW_PEGNI_CRB_AGT_ADR,
+   NETXEN_HW_PEGND_CRB_AGT_ADR,
+   NETXEN_HW_PEGNC_CRB_AGT_ADR,
+   NETXEN_HW_PEGR0_CRB_AGT_ADR,
+   NETXEN_HW_PEGR1_CRB_AGT_ADR,
+   NETXEN_HW_PEGR2_CRB_AGT_ADR,
+   NETXEN_HW_PEGR3_CRB_AGT_ADR
+};
+
+/*  Hub 5 */
+enum {
+   NETXEN_HW_PEGS0_CRB_AGT_ADR = 0x40,
+   NETXEN_HW_PEGS1_CRB_AGT_ADR,
+   NETXEN_HW_PEGS2_CRB_AGT_ADR,
+   NETXEN_HW_PEGS3_CRB_AGT_ADR,
+   NETXEN_HW_PEGSI_CRB_AGT_ADR,
+   NETXEN_HW_PEGSD_CRB_AGT_ADR,
+   NETXEN_HW_PEGSC_CRB_AGT_ADR
+};
+
+/*  Hub 6 */
+enum {
+   NETXEN_HW_CAS0_CRB_AGT_ADR = 0x46,
+   NETXEN_HW_CAS1_CRB_AGT_ADR = 0x47,
+   NETXEN_HW_CAS2_CRB_AGT_ADR = 0x48,
+   NETXEN_HW_CAS3_CRB_AGT_ADR = 0x49,
+   NETXEN_HW_NCM_CRB_AGT_ADR = 0x16,
+   NETXEN_HW_TMR_CRB_AGT_ADR = 0x17,
+   NETXEN_HW_XDMA_CRB_AGT_ADR = 0x05,
+   NETXEN_HW_OCM0_CRB_AGT_ADR = 0x06,
+   NETXEN_HW_OCM1_CRB_AGT_ADR = 0x07
+};

[PATCH 2.6.17 7/9] NetXen: hw access routines header file

2006-08-31 Thread Amit S. Kale

diff -Narup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/netxen/netxen_nic_hw.h 
linux-2.6.17/drivers/net/netxen/netxen_nic_hw.h
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_hw.h1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_hw.h 2006-08-31 
06:17:22.0 -0700
@@ -0,0 +1,499 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * Structures, enums, and macros for the MAC
+ *
+ */
+
+#ifndef __NETXEN_NIC_HW_H_
+#define __NETXEN_NIC_HW_H_
+
+#include "netxen_nic_hdr.h"
+
+/* Hardware memory size of 128 meg */
+#define NETXEN_MEMADDR_MAX (128 * 1024 * 1024)
+
+#ifndef readq
+static inline u64 readq(void __iomem * addr)
+{
+   return readl(addr) | (((u64) readl(addr + 4)) << 32LL);
+}
+#endif
+
+#ifndef writeq
+static inline void writeq(u64 val, void __iomem * addr)
+{
+   writel(((u32) (val)), (addr));
+   writel(((u32) (val >> 32)), (addr + 4));
+}
+#endif
+
+#define NETXEN_NIC_HW_BLOCK_WRITE_64(DATA_PTR, ADDR, NUM_WORDS)\
+   do {\
+   int num;\
+   u64 *a = (u64 *) (DATA_PTR);\
+   u64 *b = (u64 *) (ADDR);\
+   for (num = 0; num < (NUM_WORDS); num++) {\
+   writeq(readq(a), b);\
+   b++;\
+   a++;\
+   }   \
+   } while (0)
+
+#define NETXEN_NIC_HW_BLOCK_READ_64(DATA_PTR, ADDR, NUM_WORDS) \
+   do {\
+   int num;\
+   u64 *a = (u64 *) (DATA_PTR);\
+   u64 *b = (u64 *) (ADDR);\
+   for (num = 0; num < (NUM_WORDS); num++) {\
+   writeq(readq(b), a);\
+   b++;\
+   a++;\
+   }   \
+   } while (0)
+
+#define NETXEN_PCI_MAPSIZE_BYTES  (NETXEN_PCI_MAPSIZE << 20)
+
+#define NETXEN_NIC_LOCKED_READ_REG(X, Y)   \
+   addr = (void __iomem *)(adapter->ahw.pci_base + X); \
+   *(u32 *)Y = readl(addr);
+
+#define NETXEN_NIC_LOCKED_WRITE_REG(X, Y)  \
+   addr = (void __iomem *)(adapter->ahw.pci_base + X);  \
+   writel(*(u32 *)Y, addr);
+
+struct netxen_port;
+void netxen_nic_set_link_parameters(struct netxen_port *port);
+struct netxen_adapter;
+void netxen_nic_flash_print(struct netxen_adapter *adapter);
+int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off,
+  void *data, int len);
+void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
+unsigned long off, int data);
+int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off,
+ void *data, int len);
+
+typedef u8 netxen_ethernet_macaddr_t[6];
+
+/* Nibble or Byte mode for phy interface (GbE mode only) */
+typedef enum {
+   NETXEN_NIU_10_100_MB = 0,
+   NETXEN_NIU_1000_MB
+} netxen_niu_gbe_ifmode_t;
+
+#define _netxen_crb_set_bit(var, bit)  (var |= (1 << bit))
+#define _netxen_crb_clear_bit(var, bit) (var &= (~(1 << bit)))
+#define _netxen_crb_get_bit(var, bit)  ((var >> bit) & 0x1)
+
+/*
+ * NIU GB MAC Config Register 0 (applies to GB0, GB1, GB2, GB3)
+ *
+ * Bit 0 : enable_tx => 1:enable frame xmit, 0:disable
+ * Bit 1 : tx_synced => R/O: xmit enable synched to xmit stream
+ * Bit 2 : enable_rx => 1:enable frame recv, 0:disable
+ * Bit 3 : rx_synced => R/O: recv enable sync

[PATCH 2.6.17 6/9] NetXen: Main header file

2006-08-31 Thread Amit S. Kale

diff -Narup -X linux-2.6.17.orig/Documentation/dontdiff 
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.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic.h2006-08-31 
06:17:22.0 -0700
@@ -0,0 +1,901 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#ifndef _NETXEN_NIC_H_
+#define _NETXEN_NIC_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "netxen_nic_hw.h"
+
+#define NETXEN_NIC_BUILD_NO "232"
+#define _NETXEN_NIC_LINUX_MAJOR 2
+#define _NETXEN_NIC_LINUX_MINOR 3
+#define _NETXEN_NIC_LINUX_SUBVERSION 57
+#define NETXEN_NIC_LINUX_VERSIONID  "2.3.57"
+#define NETXEN_NIC_FW_VERSIONID "2.3.57"
+
+#define RCV_DESC_RINGSIZE  \
+   (sizeof(struct rcv_desc_t) * adapter->max_rx_desc_count)
+#define STATUS_DESC_RINGSIZE   \
+   (sizeof(struct status_desc_t)* adapter->max_rx_desc_count)
+#define TX_RINGSIZE\
+   (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count)
+#define RCV_BUFFSIZE   \
+   (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count)
+#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 __iomem *)(ptrdiff_t)((adapter)->ahw.pci_base + (reg)  \
+   - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)
+
+#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 */
+enum {
+   TX_ETHER_PKT = 0x01,
+/* The following opcodes are for IP checksum   */
+   TX_TCP_PKT,
+   TX_UDP_PKT,
+   TX_IP_PKT,
+   TX_TCP_LSO,
+   TX_IPSEC,
+   TX_IPSEC_CMD
+};
+
+/* The following opcodes are for internal consumption. */
+#define NETXEN_CONTROL_OP  0x10
+#define PEGNET_REQUEST 0x11
+
+#defineMAX_NUM_CARDS   4
+
+#define MAX_BUFFERS_PER_CMD32
+
+/*
+ * 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 0x
+#define PHAN_INITIALIZE_COMPLETE   0xff01
+
+/* Host writes the following to notify that it has done the init-handshake */
+#define PHAN_INITIALIZE_ACK0xf00f
+
+#define NUM_RCV_DESC_RINGS 2   /* No of Rcv Descriptor contexts */
+
+/* descriptor types */
+#define RCV_DESC_NORMAL0x01
+#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_DESCRIPTORS1024
+#define MAX_RCV_DESCRIPTORS32768
+#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_DESCR

[PATCH 2.6.17 5/9] NetXen: ethtool interface

2006-08-31 Thread Amit S. Kale

diff -Narup -X linux-2.6.17.orig/Documentation/dontdiff 
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.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_ethtool.c2006-08-31 
06:17:22.0 -0700
@@ -0,0 +1,696 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * ethtool support for netxen nic
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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 & 0x8000)) {
+   n &= ~0x8000;
+   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_ty

[PATCH 2.6.17 4/9] NetXen: intr routines and niu handling

2006-08-31 Thread Amit S. Kale

diff -Narup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/netxen/netxen_nic_isr.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_isr.c
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_isr.c   1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_isr.c2006-08-31 
06:17:22.0 -0700
@@ -0,0 +1,301 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#include 
+#include 
+
+#include "netxen_nic.h"
+#include "netxen_nic_hw.h"
+#include "netxen_nic_phan_reg.h"
+
+/*
+ * netxen_nic_get_stats - Get System Network Statistics
+ * @netdev: network interface device structure
+ */
+struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct net_device_stats *stats = &port->net_stats;
+
+   memset(stats, 0, sizeof(*stats));
+
+   /* total packets received   */
+   stats->rx_packets = port->stats.no_rcv;
+   /* total packets transmitted*/
+   stats->tx_packets = port->stats.xmitedframes + port->stats.xmitfinished;
+   /* total bytes received */
+   stats->rx_bytes = port->stats.rxbytes;
+   /* total bytes transmitted  */
+   stats->tx_bytes = port->stats.txbytes;
+   /* bad packets received */
+   stats->rx_errors = port->stats.rcvdbadskb;
+   /* packet transmit problems */
+   stats->tx_errors = port->stats.nocmddescriptor;
+   /* no space in linux buffers*/
+   stats->rx_dropped = port->stats.updropped;
+   /* no space available in linux  */
+   stats->tx_dropped = port->stats.txdropped;
+
+   return stats;
+}
+
+long netxen_nic_enable_phy_interrupts(struct netxen_adapter *adapter,
+ long portno)
+{
+   long result = 0;
+
+   switch (adapter->ahw.board_type) {
+   case NETXEN_NIC_GBE:
+   result = netxen_niu_gbe_enable_phy_interrupts(adapter, portno);
+   break;
+
+   case NETXEN_NIC_XGBE:
+   netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x3f);
+   break;
+
+   default:
+   printk(KERN_ERR "%s: Unknown board type\n",
+  netxen_nic_driver_name);
+   result = -1;
+   }
+
+   return result;
+}
+
+long netxen_nic_disable_phy_interrupts(struct netxen_adapter *adapter,
+  long portno)
+{
+   long result = 0;
+
+   switch (adapter->ahw.board_type) {
+   case NETXEN_NIC_GBE:
+   result = netxen_niu_gbe_disable_phy_interrupts(adapter, portno);
+   break;
+
+   case NETXEN_NIC_XGBE:
+   netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x7f);
+   break;
+
+   default:
+   printk(KERN_ERR "%s: Unknown board type\n",
+  netxen_nic_driver_name);
+   result = -1;
+   }
+
+   return result;
+}
+
+long netxen_nic_clear_phy_interrupts(struct netxen_adapter *adapter,
+long portno)
+{
+   long result = 0;
+
+   switch (adapter->ahw.board_type) {
+   case NETXEN_NIC_GBE:
+   result = netxen_niu_gbe_clear_phy_interrupts(adapter, portno);
+   break;
+
+   case NETXEN_NIC_XGBE:
+   netxen_crb_writelit_adapter(adapter, NETXEN_NIU_ACTIVE_INT, -1);
+   break;
+
+   default:
+   printk(KERN_ERR "%s: Unknown board type\n",
+  netxen_nic_driver_name);
+   result = -1;
+   }
+
+   return result;
+}
+
+void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno,
+u32 link)
+{
+   struct netxen_port *pport = adapter->port[portno];
+   struct net_device *netdev = pport->netdev;
+
+   if (link)
+   netif_carrier_on(netdev);
+   else
+   netif_ca

[PATCH 2.6.17 3/9] NetXen: hw initialization routines

2006-08-31 Thread Amit S. Kale

diff -Narup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/netxen/netxen_nic_init.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_init.c
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_init.c  1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_init.c   2006-08-31 
06:17:22.0 -0700
@@ -0,0 +1,1089 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * Source file for NIC routines to initialize the Phantom Hardware
+ *
+ */
+
+#include 
+#include 
+#include "netxen_nic.h"
+#include "netxen_nic_hw.h"
+#include "netxen_nic_ioctl.h"
+#include "netxen_nic_phan_reg.h"
+
+struct crb_addr_pair {
+   long addr;
+   long data;
+};
+
+#define NETXEN_MAX_CRB_XFORM 60
+static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM];
+#define NETXEN_ADDR_ERROR ((unsigned long ) 0x )
+
+#define crb_addr_transform(name) \
+   crb_addr_xform[NETXEN_HW_PX_MAP_CRB_##name] = \
+   NETXEN_HW_CRB_HUB_AGT_ADR_##name << 20
+
+static void crb_addr_transform_setup(void)
+{
+   crb_addr_transform(XDMA);
+   crb_addr_transform(TIMR);
+   crb_addr_transform(SRE);
+   crb_addr_transform(SQN3);
+   crb_addr_transform(SQN2);
+   crb_addr_transform(SQN1);
+   crb_addr_transform(SQN0);
+   crb_addr_transform(SQS3);
+   crb_addr_transform(SQS2);
+   crb_addr_transform(SQS1);
+   crb_addr_transform(SQS0);
+   crb_addr_transform(RPMX7);
+   crb_addr_transform(RPMX6);
+   crb_addr_transform(RPMX5);
+   crb_addr_transform(RPMX4);
+   crb_addr_transform(RPMX3);
+   crb_addr_transform(RPMX2);
+   crb_addr_transform(RPMX1);
+   crb_addr_transform(RPMX0);
+   crb_addr_transform(ROMUSB);
+   crb_addr_transform(SN);
+   crb_addr_transform(QMN);
+   crb_addr_transform(QMS);
+   crb_addr_transform(PGNI);
+   crb_addr_transform(PGND);
+   crb_addr_transform(PGN3);
+   crb_addr_transform(PGN2);
+   crb_addr_transform(PGN1);
+   crb_addr_transform(PGN0);
+   crb_addr_transform(PGSI);
+   crb_addr_transform(PGSD);
+   crb_addr_transform(PGS3);
+   crb_addr_transform(PGS2);
+   crb_addr_transform(PGS1);
+   crb_addr_transform(PGS0);
+   crb_addr_transform(PS);
+   crb_addr_transform(PH);
+   crb_addr_transform(NIU);
+   crb_addr_transform(I2Q);
+   crb_addr_transform(EG);
+   crb_addr_transform(MN);
+   crb_addr_transform(MS);
+   crb_addr_transform(CAS2);
+   crb_addr_transform(CAS1);
+   crb_addr_transform(CAS0);
+   crb_addr_transform(CAM);
+   crb_addr_transform(C2C1);
+   crb_addr_transform(C2C0);
+}
+
+int netxen_init_firmware(struct netxen_adapter *adapter)
+{
+   u32 state = 0, loops = 0, err = 0;
+
+   /* Window 1 call */
+   state = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
+
+   if (state == PHAN_INITIALIZE_ACK)
+   return 0;
+
+   while (state != PHAN_INITIALIZE_COMPLETE && loops < 2000) {
+   udelay(100);
+   /* Window 1 call */
+   state = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
+
+   loops++;
+   }
+   if (loops >= 2000) {
+   printk(KERN_ERR "Cmd Peg initialization not complete:%x.\n",
+  state);
+   err = -EIO;
+   return err;
+   }
+   /* Window 1 call */
+   writel(PHAN_INITIALIZE_ACK,
+  NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
+
+   return err;
+}
+
+void netxen_initialize_adapter_sw(struct netxen_adapter *adapter)
+{
+   int ctxid, ring;
+   u32 i;
+   u32 num_rx_bufs = 0;
+   struct netxen_rcv_desc_ctx *rcv_desc;
+
+   DPRINTK(INFO, "initializing some queues: %p\n", adapter);
+   for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) {
+   for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
+   struct net

[PATCH 2.6.17 2/9] NetXen: Hardware access routines

2006-08-31 Thread Amit S. Kale

diff -Narup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/netxen/netxen_nic_hw.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_hw.c1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c 2006-08-31 
06:17:22.0 -0700
@@ -0,0 +1,1102 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * Source file for NIC routines to access the Phantom hardware
+ *
+ */
+
+#include "netxen_nic.h"
+#include "netxen_nic_hw.h"
+#include "netxen_nic_phan_reg.h"
+
+/*  PCI Windowing for DDR regions.  */
+
+#define ADDR_IN_RANGE(addr, low, high) \
+   (((addr) <= (high)) && ((addr) >= (low)))
+
+#define NETXEN_FLASH_BASE  (BOOTLD_START)
+#define NETXEN_PHANTOM_MEM_BASE(NETXEN_FLASH_BASE)
+#define NETXEN_MAX_MTU 8000
+#define NETXEN_MTU_MASK0x
+#define NETXEN_WINDOW_ONE 0x200/* CRB Window: bit 25 of CRB address */
+
+unsigned long netxen_nic_pci_set_window(void __iomem * pci_base,
+   unsigned long long addr);
+void netxen_free_hw_resources(struct netxen_adapter *adapter);
+
+int netxen_nic_set_mac(struct net_device *netdev, void *p)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct sockaddr *addr = p;
+
+   if (netif_running(netdev))
+   return -EBUSY;
+
+   if (!is_valid_ether_addr(addr->sa_data))
+   return -EADDRNOTAVAIL;
+
+   DPRINTK(INFO, "valid ether addr\n");
+   memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
+
+   netxen_nic_macaddr_set(port, addr->sa_data);
+
+   return 0;
+}
+
+/**
+ * netxen_nic_set_multi - Multicast
+ **/
+void netxen_nic_set_multi(struct net_device *netdev)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct dev_mc_list *mc_ptr;
+
+   mc_ptr = netdev->mc_list;
+   if (netdev->flags & IFF_PROMISC)
+   netxen_nic_set_promisc_mode(port);
+   else
+   netxen_nic_unset_promisc_mode(port);
+}
+
+/*
+ * netxen_nic_change_mtu - Change the Maximum Transfer Unit
+ * @returns 0 on success, negative on failure
+ */
+int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+
+   if (new_mtu & NETXEN_MTU_MASK)
+   return -EINVAL;
+
+   if (new_mtu > NETXEN_MAX_MTU) {
+   printk(KERN_ERR
+  "%s: %s MTU > NETXEN_MAX_MTU is not supported\n",
+  netxen_nic_driver_name, netdev->name);
+   return -EINVAL;
+   }
+
+   netxen_nic_set_mtu(port, new_mtu);
+   netdev->mtu = new_mtu;
+
+   return 0;
+}
+
+/*
+ * check if the firmware has been downloaded and ready to run  and
+ * setup the address for the descriptors in the adapter
+ */
+int netxen_nic_hw_resources(struct netxen_adapter *adapter)
+{
+   struct netxen_hardware_context *hw = &adapter->ahw;
+   int i;
+   u32 state = 0;
+   void *addr;
+   int loops = 0, err = 0;
+   int ctx, ring;
+   u32 card_cmdring = 0;
+   struct netxen_rcv_desc_crb *rcv_desc_crb = NULL;
+   struct netxen_recv_context *recv_ctx;
+   struct netxen_rcv_desc_ctx *rcv_desc;
+   struct cmd_desc_type0_t *pcmd;
+
+   DPRINTK(INFO, "pci_base: %lx\n", adapter->ahw.pci_base);
+   DPRINTK(INFO, "crb_base: %lx %lx", NETXEN_PCI_CRBSPACE,
+   adapter->ahw.pci_base + NETXEN_PCI_CRBSPACE);
+   DPRINTK(INFO, "cam base: %lx %lx", NETXEN_CRB_CAM,
+   adapter->ahw.pci_base + NETXEN_CRB_CAM);
+   DPRINTK(INFO, "cam RAM: %lx %lx", NETXEN_CAM_RAM_BASE,
+   adapter->ahw.pci_base + NETXEN_CAM_RAM_BASE);
+   DPRINTK(INFO, "NIC base:%lx %lx\n", NIC_CRB_BASE_PORT1,
+   adapter->ahw.pci_base + NIC_CRB_BASE_PORT1);
+
+   /* Window 1 call */
+   card_cmdring = readl(NETXEN_C

[PATCH 2.6.17 1/9] NetXen: Makefile and driver main file

2006-08-31 Thread Amit S. Kale

diff -Narup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/MAINTAINERS linux-2.6.17/MAINTAINERS
--- linux-2.6.17.orig/MAINTAINERS   2006-08-30 06:51:57.0 -0700
+++ linux-2.6.17/MAINTAINERS2006-08-30 06:56:27.0 -0700
@@ -1987,6 +1987,13 @@ L:   netdev@vger.kernel.org
 T: git kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6.git
 S: Maintained

+NETXEN (1/10) GbE SUPPORT
+P: Amit S. Kale
+M: [EMAIL PROTECTED]
+L: netdev@vger.kernel.org
+W: http://www.netxen.com
+S: Supported
+
 IPVS
 P: Wensong Zhang
 M: [EMAIL PROTECTED]
diff -Narup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/Kconfig linux-2.6.17/drivers/net/Kconfig
--- linux-2.6.17.orig/drivers/net/Kconfig   2006-08-30 06:51:55.0 
-0700
+++ linux-2.6.17/drivers/net/Kconfig2006-08-30 06:54:30.0 -0700
@@ -2311,6 +2311,11 @@ config S2IO_NAPI

  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 -Narup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/Makefile linux-2.6.17/drivers/net/Makefile
--- linux-2.6.17.orig/drivers/net/Makefile  2006-08-30 06:51:55.0 
-0700
+++ linux-2.6.17/drivers/net/Makefile   2006-08-30 06:52:15.0 -0700
@@ -213,3 +213,4 @@ obj-$(CONFIG_NETCONSOLE) += netconsole.o

 obj-$(CONFIG_FS_ENET) += fs_enet/

+obj-$(CONFIG_NETXEN_NIC) += netxen/
diff -Narup -X linux-2.6.17.orig/Documentation/dontdiff 
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.0 -0800
+++ linux-2.6.17/drivers/net/netxen/Makefile2006-08-31 06:17:22.0 
-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:

+#[EMAIL PROTECTED]
+# 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 -Narup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/netxen/netxen_nic_main.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_main.c
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_main.c  1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_main.c   2006-08-31 
06:17:22.0 -0700
@@ -0,0 +1,1107 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ *  Main source file for NetXen NIC Driver on Linux
+ *
+ */
+
+#include "netxen_nic_hw.h"
+
+#include "netxen_nic.h"
+#define DEFINE_GLOBAL_RECV_CRB
+#include "netxen_nic_phan_reg.h"
+#include "netxen_nic_ioctl.h"
+
+MODULE_DESCRIPTION("NetXen Multi port (1

[PATCH 2.6.17 0/9] NetXen: 1G/10G Ethernet Driver

2006-08-31 Thread Amit S. Kale

Hi All,

Thank you Stephen, Don and Wendy.
We have incorporated feedbacks which have received since after last post. 
I'll be resending updated patchset in subsequent emails.


We are working on finding out good way of using tables to manage 
compatibility between firmware version number and driver version number.


Kindly review it and feel free to send feedback.

Thanks,
-Amit

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

 MAINTAINERS  |7
 drivers/net/Kconfig  |5
 drivers/net/Makefile |1
 drivers/net/netxen/Makefile  |   35
 drivers/net/netxen/netxen_nic.h  |  901 +
 drivers/net/netxen/netxen_nic_ethtool.c  |  696 +++
 drivers/net/netxen/netxen_nic_hdr.h  |  611 +
 drivers/net/netxen/netxen_nic_hw.c   | 1102 ++
 drivers/net/netxen/netxen_nic_hw.h   |  499 +
 drivers/net/netxen/netxen_nic_init.c | 1089 ++
 drivers/net/netxen/netxen_nic_ioctl.h|   75 ++
 drivers/net/netxen/netxen_nic_isr.c  |  301 
 drivers/net/netxen/netxen_nic_main.c | 1107 +++
 drivers/net/netxen/netxen_nic_niu.c  |  779 +
 drivers/net/netxen/netxen_nic_phan_reg.h |  195 +
 15 files changed, 7403 insertions(+)
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.17 2/9] NetXen: Hardware access routines

2006-08-28 Thread Amit S. Kale
On Monday 21 August 2006 19:33, Stephen Hemminger wrote:
> On Mon, 21 Aug 2006 13:57:23 +0530
>
> "Amit S. Kale" <[EMAIL PROTECTED]> wrote:
> > We can certainly create a table for all error messages. It'll hurt
> > readability of code in many of the other places where printks are used to
> > indicate some hardware error.
> > -Amit
>
> My suggestion was intended as an way to handle multiple driver versions
> all using the same firmware or vice versa. By locking the firmware and
> driver version together you might make maintenance more difficult.

Ah, I had missed that completely in your first email. Thanks for your 
suggestion.

The NetXen firmware will most probably keep changing. It's hardware is 
flexible enough, so the firmware changes will possibly be varied in nature. 
Thinking about this further, it seems we should coalesce firmware dependent 
code into a few isolated functions. While this may be difficult, we should do 
it anyway. Hopefully future changes will not cause these efforts to go waste.
-Amit

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


Re: [PATCH 2.6.17 0/9] NetXen: 1G/10G Ethernet Driver

2006-08-25 Thread Amit S. Kale
Hi Don,

Thanks. We'll lindent the sources and post an update asap.
-Amit

On Thursday 24 August 2006 05:34, Don Fry wrote:
> It looks like you have not run the source throught Lindent as previously
> requested.  Before you submit the code again, please use the Lindent
> script.
>
> I can get the code to ping between two cards.  Will be doing more
> testing tomorrow.
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.17 0/9] NetXen: 1G/10G Ethernet Driver - patch for big-endian systems

2006-08-25 Thread Amit S. Kale
Wendy, Michael, Ueimor,

Thanks for the patch and feedback. We'll integrate these into our driver and 
post an update asap.

-Amit

On Friday 25 August 2006 03:10, Francois Romieu wrote:
> wen xiong <[EMAIL PROTECTED]> :
> [...]
>
> > diff -Nuar old/drivers/net/netxen/netxen_nic_hw.c
> > new/drivers/net/netxen/netxen_nic_hw.c ---
> > old/drivers/net/netxen/netxen_nic_hw.c  2006-08-23 12:58:43.0
> > -0500 +++ new/drivers/net/netxen/netxen_nic_hw.c2006-08-23
> > 13:15:19.0 -0500 @@ -313,7 +313,8 @@
> > }
> > }
> > CMD_DESC_TCP_HDR_OFFSET_WRT(desc, skb->h.raw - skb->data);
> > -   desc->ip_hdr_offset = skb->nh.raw - skb->data;
> > +   desc->length_tcp_hdr=cpu_to_le32(desc->length_tcp_hdr);
>
> s/=/ = /
>
> (several occurences)
>
> [...]
>
> > diff -Nuar old/drivers/net/netxen/netxen_nic_init.c
> > new/drivers/net/netxen/netxen_nic_init.c ---
> > old/drivers/net/netxen/netxen_nic_init.c2006-08-23 12:58:43.0
> > -0500 +++ new/drivers/net/netxen/netxen_nic_init.c  2006-08-23
> > 13:15:19.0 -0500 @@ -494,7 +494,7 @@
> > desc_head = recv_ctx->rcv_status_desc_head;
> > desc = &desc_head[consumer];
> >
> > -   if ((desc->owner & STATUS_OWNER_HOST))
> > +   if (((le16_to_cpu(desc->owner)) & STATUS_OWNER_HOST))
>
> Would it make a difference to swab the constant part, i.e.:
>
>   if (desc->owner & cpu_to_le16(STATUS_OWNER_HOST))
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.17 4/9] NetXen: intr routines and niu handling

2006-08-21 Thread Amit S. Kale
On Friday 18 August 2006 20:52, Stephen Hemminger wrote:
>
> Why keep track of statistics in one structure then copy out to net_device
> format? Instead just use original format.

net_device structure contains "unsigned long" fields. netxen_port_stats 
contains u64 fields. rx_bytes and tx_bytes can easily overflow for 10G cards.

ethtool_status contains u64 stats; is it a good time to make net_device_stats 
64 bit?

-Amit
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.17 2/9] NetXen: Hardware access routines

2006-08-21 Thread Amit S. Kale
We can certainly create a table for all error messages. It'll hurt readability 
of code in many of the other places where printks are used to indicate some 
hardware error.
-Amit

On Friday 18 August 2006 20:46, Stephen Hemminger wrote:
> > +   if (fw_major != _NETXEN_NIC_LINUX_MAJOR) {
> > +   printk(KERN_ERR "The mismatch in driver version and firmware "
> > +   "version major number\n"
> > +   "Driver version major number = %d \t"
> > +   "Firmware version major number = %d \n",
> > +   _NETXEN_NIC_LINUX_MAJOR, fw_major);
> > +   adapter->driver_mismatch = 1;
> > +   }
> > +   if (fw_minor != _NETXEN_NIC_LINUX_MINOR) {
> > +   printk(KERN_ERR "The mismatch in driver version and firmware "
> > +   "version minor number\n"
> > +   "Driver version minor number = %d \t"
> > +   "Firmware version minor number = %d \n",
> > +   _NETXEN_NIC_LINUX_MINOR, fw_minor);
> > +   adapter->driver_mismatch = 1;
> > +   }
>
> You might want a table for this?
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2.6.17 7/9] NetXen: hw access routines header file

2006-08-18 Thread Amit S. Kale

diff -Nrup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/netxen/netxen_nic_hw.h 
linux-2.6.17/drivers/net/netxen/netxen_nic_hw.h
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_hw.h1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_hw.h 2006-08-17 
07:12:34.0 -0700
@@ -0,0 +1,500 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * Structures, enums, and macros for the MAC
+ *
+ */
+
+#ifndef __NETXEN_NIC_HW_H_
+#define __NETXEN_NIC_HW_H_
+
+#include "netxen_nic_hdr.h"
+
+/* Hardware memory size of 128 meg */
+#define NETXEN_MEMADDR_MAX (128 * 1024 * 1024)
+
+#ifndef readq
+static inline u64 readq(void __iomem * addr)
+{
+   return readl(addr) | (((u64) readl(addr + 4)) << 32LL);
+}
+#endif
+
+#ifndef writeq
+static inline void writeq(u64 val, void __iomem * addr)
+{
+   writel(((u32) (val)), (addr));
+   writel(((u32) (val >> 32)), (addr + 4));
+}
+#endif
+
+#define NETXEN_NIC_HW_BLOCK_WRITE_64(DATA_PTR, ADDR, NUM_WORDS)\
+   do {\
+   int num;\
+   u64 *a = (u64 *) (DATA_PTR);\
+   u64 *b = (u64 *) (ADDR);\
+   for (num = 0; num < (NUM_WORDS); num++) {\
+   writeq(readq(a), b);\
+   b++;\
+   a++;\
+   }   \
+   } while (0)
+
+#define NETXEN_NIC_HW_BLOCK_READ_64(DATA_PTR, ADDR, NUM_WORDS) \
+   do {\
+   int num;\
+   u64 *a = (u64 *) (DATA_PTR);\
+   u64 *b = (u64 *) (ADDR);\
+   for (num = 0; num < (NUM_WORDS); num++) {\
+   writeq(readq(b), a);\
+   b++;\
+   a++;\
+   }   \
+   } while (0)
+
+#define NETXEN_PCI_MAPSIZE_BYTES  (NETXEN_PCI_MAPSIZE << 20)
+
+#define NETXEN_NIC_LOCKED_READ_REG(X, Y)   \
+   addr = (void __iomem *)(adapter->ahw.pci_base + X); \
+   *(u32 *)Y = readl(addr);
+
+#define NETXEN_NIC_LOCKED_WRITE_REG(X, Y)  \
+   addr = (void __iomem *)(adapter->ahw.pci_base + X);  \
+   writel(*(u32 *)Y, addr);
+
+struct netxen_port;
+void netxen_nic_set_link_parameters(struct netxen_port *port);
+struct netxen_adapter;
+void netxen_nic_flash_print(struct netxen_adapter *adapter);
+int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off,
+  void *data, int len);
+void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
+unsigned long off, int data);
+int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off,
+ void *data, int len);
+
+typedef u8 netxen_ethernet_macaddr_t[6];
+
+/* Nibble or Byte mode for phy interface (GbE mode only) */
+typedef enum {
+   NETXEN_NIU_10_100_MB = 0,
+   NETXEN_NIU_1000_MB
+} netxen_niu_gbe_ifmode_t;
+
+#define _netxen_crb_set_bit(var, bit)  (var |= (1 << bit))
+#define _netxen_crb_clear_bit(var, bit) (var &= (~(1 << bit)))
+#define _netxen_crb_get_bit(var, bit)  ((var >> bit) & 0x1)
+
+/*
+ * NIU GB MAC Config Register 0 (applies to GB0, GB1, GB2, GB3)
+ *
+ * Bit 0 : enable_tx => 1:enable frame xmit, 0:disable
+ * Bit 1 : tx_synced => R/O: xmit enable synched to xmit stream
+ * Bit 2 : enable_rx => 1:enable frame recv, 0:disable
+ * Bit 3 : rx_synced => R/O: recv enable synch

[PATCH 2.6.17 9/9] NetXen: CRB reg defininitions

2006-08-18 Thread Amit S. Kale

diff -Nrup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/netxen/netxen_nic_phan_reg.h 
linux-2.6.17/drivers/net/netxen/netxen_nic_phan_reg.h
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_phan_reg.h  1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_phan_reg.h   2006-08-17 
07:12:34.0 -0700
@@ -0,0 +1,195 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#ifndef __NIC_PHAN_REG_H_
+#define __NIC_PHAN_REG_H_
+
+/** 
+ * CRB Registers or queue message done only at initialization time

+ **/
+
+/**
+ * The following 2 are the base adresses for the CRB registers and their
+ * offsets will be added to get addresses for the index addresses...
+ **/
+#define NIC_CRB_BASE_PORT1 NETXEN_CAM_RAM(0x200)
+#define NIC_CRB_BASE_PORT2 NETXEN_CAM_RAM(0x250)
+
+#define NETXEN_NIC_REG(X)  (NIC_CRB_BASE_PORT1+(X))
+
+/**
+ * CrbPortPhanCntrHi/Lo is used to pass the address of HostPhantomIndex address
+ * which can be read by the Phantom host to get producer/consumer indexes from
+ * Phantom/Casper. If it is not HOST_SHARED_MEMORY, then the following
+ * registers will be used for the addresses of the ring's shared memory
+ * on the Phantom.
+ **/
+
+#define CRB_PHAN_CNTRL_LO_OFFSET   NETXEN_NIC_REG(0x00)
+#define CRB_PHAN_CNTRL_HI_OFFSET   NETXEN_NIC_REG(0x04)
+
+/* point to the indexes */
+#define CRB_CMD_PRODUCER_OFFSETNETXEN_NIC_REG(0x08)
+#define CRB_CMD_CONSUMER_OFFSETNETXEN_NIC_REG(0x0c)
+
+/* address of command descriptors in the host memory */
+#define CRB_HOST_CMD_ADDR_HI   NETXEN_NIC_REG(0x30)
+#define CRB_HOST_CMD_ADDR_LO   NETXEN_NIC_REG(0x34)
+
+/* The following 4 CRB registers are for doing performance coal */
+#define CRB_CMD_INTR_LOOP  NETXEN_NIC_REG(0x38)
+#define CRB_CMD_DMA_LOOP   NETXEN_NIC_REG(0x3c)
+#define CRB_RCV_INTR_LOOP  NETXEN_NIC_REG(0x40)
+#define CRB_RCV_DMA_LOOP   NETXEN_NIC_REG(0x44)
+
+/* Needed by the host to find out the state of Phantom's initialization */
+#define CRB_ENABLE_TX_INTR NETXEN_NIC_REG(0x4c)
+#define CRB_CMDPEG_STATE   NETXEN_NIC_REG(0x50)
+#define CRB_CMDPEG_CMDRING NETXEN_NIC_REG(0x54)
+
+/* Interrupt coalescing parameters */
+#define CRB_GLOBAL_INT_COALNETXEN_NIC_REG(0x80)
+#define CRB_INT_COAL_MODE  NETXEN_NIC_REG(0x84)
+#define CRB_MAX_RCV_BUFS   NETXEN_NIC_REG(0x88)
+#define CRB_TX_INT_THRESHOLD   NETXEN_NIC_REG(0x8c)
+#define CRB_RX_PKT_TIMER   NETXEN_NIC_REG(0x90)
+#define CRB_TX_PKT_TIMER   NETXEN_NIC_REG(0x94)
+#define CRB_RX_PKT_CNT NETXEN_NIC_REG(0x98)
+#define CRB_RX_TMR_CNT NETXEN_NIC_REG(0x9c)
+
+/* Register for communicating XG link status */
+#define CRB_XG_STATE   NETXEN_NIC_REG(0xa0)
+
+/* Debug registers for controlling NIC pkt gen agent */
+#define CRB_AGENT_GO   NETXEN_NIC_REG(0xb0)
+#define CRB_AGENT_TX_SIZE  NETXEN_NIC_REG(0xb4)
+#define CRB_AGENT_TX_TYPE  NETXEN_NIC_REG(0xb8)
+#define CRB_AGENT_TX_ADDR  NETXEN_NIC_REG(0xbc)
+#define CRB_AGENT_TX_MSS   NETXEN_NIC_REG(0xc0)
+
+/* Debug registers for observing NIC performance */
+#define CRB_TX_STATE   NETXEN_NIC_REG(0xd0)
+#define CRB_TX_COUNT   NETXEN_NIC_REG(0xd4)
+#define CRB_RX_STATE   NETXEN_NIC_REG(0xd8)
+
+/* CRB registers per Rcv Descriptor ring */
+struct netxen_rcv_desc_crb {
+   u32 crb_rcv_producer_offset __attribute__ ((aligned(512)));
+   u32 crb_rcv_consumer_offset;
+   u32 crb_globalrcv_ring;
+};
+
+/*
+ * CRB registers used by the receive peg logic. One instance of these
+ * needs to be instantiated per instance of the receive peg.
+ */
+
+struct netxen_recv_crb {
+   struct netxen_rcv_desc_crb rcv_desc_crb[NUM_RC

[PATCH 2.6.17 8/9] NetXen: Header file and ioctl header file

2006-08-18 Thread Amit S. Kale

diff -Nrup -X linux-2.6.17.orig/Documentation/dontdiff 
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.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_hdr.h2006-08-17 
07:12:34.0 -0700
@@ -0,0 +1,611 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#ifndef __NETXEN_NIC_HDR_H_
+#define __NETXEN_NIC_HDR_H_
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include   /* for memset */
+
+/*
+ * The basic unit of access when reading/writing control registers.
+ */
+
+typedef __le32 netxen_crbword_t;   /* single word in CRB space */
+
+enum {
+   NETXEN_HW_H0_CH_HUB_ADR = 0x05,
+   NETXEN_HW_H1_CH_HUB_ADR = 0x0E,
+   NETXEN_HW_H2_CH_HUB_ADR = 0x03,
+   NETXEN_HW_H3_CH_HUB_ADR = 0x01,
+   NETXEN_HW_H4_CH_HUB_ADR = 0x06,
+   NETXEN_HW_H5_CH_HUB_ADR = 0x07,
+   NETXEN_HW_H6_CH_HUB_ADR = 0x08
+};
+
+/*  Hub 0 */
+enum {
+   NETXEN_HW_MN_CRB_AGT_ADR = 0x15,
+   NETXEN_HW_MS_CRB_AGT_ADR = 0x25
+};
+
+/*  Hub 1 */
+enum {
+   NETXEN_HW_PS_CRB_AGT_ADR= 0x73,
+   NETXEN_HW_SS_CRB_AGT_ADR= 0x20,
+   NETXEN_HW_RPMX3_CRB_AGT_ADR = 0x0b,
+   NETXEN_HW_QMS_CRB_AGT_ADR   = 0x00,
+   NETXEN_HW_SQGS0_CRB_AGT_ADR = 0x01,
+   NETXEN_HW_SQGS1_CRB_AGT_ADR = 0x02,
+   NETXEN_HW_SQGS2_CRB_AGT_ADR = 0x03,
+   NETXEN_HW_SQGS3_CRB_AGT_ADR = 0x04,
+   NETXEN_HW_C2C0_CRB_AGT_ADR  = 0x58,
+   NETXEN_HW_C2C1_CRB_AGT_ADR  = 0x59,
+   NETXEN_HW_C2C2_CRB_AGT_ADR  = 0x5a,
+   NETXEN_HW_RPMX2_CRB_AGT_ADR = 0x0a,
+   NETXEN_HW_RPMX4_CRB_AGT_ADR = 0x0c,
+   NETXEN_HW_RPMX7_CRB_AGT_ADR = 0x0f,
+   NETXEN_HW_RPMX9_CRB_AGT_ADR = 0x12,
+   NETXEN_HW_SMB_CRB_AGT_ADR   = 0x18
+};
+
+/*  Hub 2 */
+enum {
+   NETXEN_HW_NIU_CRB_AGT_ADR   = 0x31,
+   NETXEN_HW_I2C0_CRB_AGT_ADR  = 0x19,
+   NETXEN_HW_I2C1_CRB_AGT_ADR  = 0x29,
+
+   NETXEN_HW_SN_CRB_AGT_ADR= 0x10,
+   NETXEN_HW_I2Q_CRB_AGT_ADR   = 0x20,
+   NETXEN_HW_LPC_CRB_AGT_ADR   = 0x22,
+   NETXEN_HW_ROMUSB_CRB_AGT_ADR= 0x21,
+   NETXEN_HW_QM_CRB_AGT_ADR= 0x66,
+   NETXEN_HW_SQG0_CRB_AGT_ADR  = 0x60,
+   NETXEN_HW_SQG1_CRB_AGT_ADR  = 0x61,
+   NETXEN_HW_SQG2_CRB_AGT_ADR  = 0x62,
+   NETXEN_HW_SQG3_CRB_AGT_ADR  = 0x63,
+   NETXEN_HW_RPMX1_CRB_AGT_ADR = 0x09,
+   NETXEN_HW_RPMX5_CRB_AGT_ADR = 0x0d,
+   NETXEN_HW_RPMX6_CRB_AGT_ADR = 0x0e,
+   NETXEN_HW_RPMX8_CRB_AGT_ADR = 0x11
+};
+
+/*  Hub 3 */
+enum {
+   NETXEN_HW_PH_CRB_AGT_ADR= 0x1A,
+   NETXEN_HW_SRE_CRB_AGT_ADR   = 0x50,
+   NETXEN_HW_EG_CRB_AGT_ADR= 0x51,
+   NETXEN_HW_RPMX0_CRB_AGT_ADR = 0x08
+};
+
+/*  Hub 4 */
+enum {
+   NETXEN_HW_PEGN0_CRB_AGT_ADR = 0x40,
+   NETXEN_HW_PEGN1_CRB_AGT_ADR,
+   NETXEN_HW_PEGN2_CRB_AGT_ADR,
+   NETXEN_HW_PEGN3_CRB_AGT_ADR,
+   NETXEN_HW_PEGNI_CRB_AGT_ADR,
+   NETXEN_HW_PEGND_CRB_AGT_ADR,
+   NETXEN_HW_PEGNC_CRB_AGT_ADR,
+   NETXEN_HW_PEGR0_CRB_AGT_ADR,
+   NETXEN_HW_PEGR1_CRB_AGT_ADR,
+   NETXEN_HW_PEGR2_CRB_AGT_ADR,
+   NETXEN_HW_PEGR3_CRB_AGT_ADR
+};
+
+/*  Hub 5 */
+enum {
+   NETXEN_HW_PEGS0_CRB_AGT_ADR = 0x40,
+   NETXEN_HW_PEGS1_CRB_AGT_ADR,
+   NETXEN_HW_PEGS2_CRB_AGT_ADR,
+   NETXEN_HW_PEGS3_CRB_AGT_ADR,
+   NETXEN_HW_PEGSI_CRB_AGT_ADR,
+   NETXEN_HW_PEGSD_CRB_AGT_ADR,
+   NETXEN_HW_PEGSC_CRB_AGT_ADR
+};
+
+/*  Hub 6 */
+enum {
+   NETXEN_HW_CAS0_CRB_AGT_ADR  = 0x46,
+   NETXEN_HW_CAS1_CRB_AGT_ADR  = 0x47,
+   NETXEN_HW_CAS2_CRB_AGT_ADR  = 0x48,
+   NETXEN_HW_CAS3_CRB_AGT_ADR  = 0x49,
+ 

[PATCH 2.6.17 6/9] NetXen: Main header file

2006-08-18 Thread Amit S. Kale

diff -Nrup -X linux-2.6.17.orig/Documentation/dontdiff 
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.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic.h2006-08-17 
07:12:34.0 -0700
@@ -0,0 +1,901 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#ifndef _NETXEN_NIC_H_
+#define _NETXEN_NIC_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "netxen_nic_hw.h"
+
+#define NETXEN_NIC_BUILD_NO "232"
+#define _NETXEN_NIC_LINUX_MAJOR 2
+#define _NETXEN_NIC_LINUX_MINOR 3
+#define _NETXEN_NIC_LINUX_SUBVERSION 57
+#define NETXEN_NIC_LINUX_VERSIONID  "2.3.57"
+#define NETXEN_NIC_FW_VERSIONID "2.3.57"
+
+#define RCV_DESC_RINGSIZE  \
+   (sizeof(struct rcv_desc_t) * adapter->max_rx_desc_count)
+#define STATUS_DESC_RINGSIZE   \
+   (sizeof(struct status_desc_t)* adapter->max_rx_desc_count)
+#define TX_RINGSIZE\
+   (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count)
+#define RCV_BUFFSIZE   \
+   (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count)
+#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 __iomem *)(ptrdiff_t)((adapter)->ahw.pci_base + (reg)  \
+   - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)
+
+#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 */
+enum {
+   TX_ETHER_PKT = 0x01,
+/* The following opcodes are for IP checksum   */
+   TX_TCP_PKT,
+   TX_UDP_PKT,
+   TX_IP_PKT,
+   TX_TCP_LSO,
+   TX_IPSEC,
+   TX_IPSEC_CMD
+};
+
+/* The following opcodes are for internal consumption. */
+#define NETXEN_CONTROL_OP  0x10
+#define PEGNET_REQUEST 0x11
+
+#defineMAX_NUM_CARDS   4
+
+#define MAX_BUFFERS_PER_CMD32
+
+/*
+ * 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 0x
+#define PHAN_INITIALIZE_COMPLETE   0xff01
+
+/* Host writes the following to notify that it has done the init-handshake */
+#define PHAN_INITIALIZE_ACK0xf00f
+
+#define NUM_RCV_DESC_RINGS 2   /* No of Rcv Descriptor contexts */
+
+/* descriptor types */
+#define RCV_DESC_NORMAL0x01
+#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_DESCRIPTORS1024
+#define MAX_RCV_DESCRIPTORS32768
+#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_DESCRI

[PATCH 2.6.17 5/9] NetXen: ethtool interface

2006-08-18 Thread Amit S. Kale

diff -Nrup -X linux-2.6.17.orig/Documentation/dontdiff 
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.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_ethtool.c2006-08-17 
07:12:34.0 -0700
@@ -0,0 +1,696 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * ethtool support for netxen nic
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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 & 0x8000)) {
+   n &= ~0x8000;
+   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_typ

[PATCH 2.6.17 4/9] NetXen: intr routines and niu handling

2006-08-18 Thread Amit S. Kale

diff -Nrup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/netxen/netxen_nic_isr.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_isr.c
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_isr.c   1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_isr.c2006-08-17 
07:12:34.0 -0700
@@ -0,0 +1,300 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#include 
+#include 
+
+#include "netxen_nic.h"
+#include "netxen_nic_hw.h"
+#include "netxen_nic_phan_reg.h"
+
+/*
+ * netxen_nic_get_stats - Get System Network Statistics
+ * @netdev: network interface device structure
+ */
+struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct net_device_stats *stats = &port->net_stats;
+
+   memset(stats, 0, sizeof(*stats));
+
+   /* total packets received   */
+   stats->rx_packets = port->stats.no_rcv;
+   /* total packets transmitted*/
+   stats->tx_packets = port->stats.xmitedframes + port->stats.xmitfinished;
+   /* total bytes received */
+   stats->rx_bytes = port->stats.rxbytes;
+   /* total bytes transmitted  */
+   stats->tx_bytes = port->stats.txbytes;
+   /* bad packets received */
+   stats->rx_errors = port->stats.rcvdbadskb;
+   /* packet transmit problems */
+   stats->tx_errors = port->stats.nocmddescriptor;
+   /* no space in linux buffers*/
+   stats->rx_dropped = port->stats.updropped;
+   /* no space available in linux  */
+   stats->tx_dropped = port->stats.txdropped;
+
+   return stats;
+}
+
+long netxen_nic_enable_phy_interrupts(struct netxen_adapter *adapter,
+ long portno)
+{
+   long result = 0;
+
+   switch (adapter->ahw.board_type) {
+   case NETXEN_NIC_GBE:
+   result = netxen_niu_gbe_enable_phy_interrupts(adapter, portno);
+   break;
+
+   case NETXEN_NIC_XGBE:
+   netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x3f);
+   break;
+
+   default:
+   printk(KERN_ERR "%s: Unknown board type\n",
+  netxen_nic_driver_name);
+   result = -1;
+   }
+
+   return result;
+}
+
+long netxen_nic_disable_phy_interrupts(struct netxen_adapter *adapter,
+  long portno)
+{
+   long result = 0;
+
+   switch (adapter->ahw.board_type) {
+   case NETXEN_NIC_GBE:
+   result = netxen_niu_gbe_disable_phy_interrupts(adapter, portno);
+   break;
+
+   case NETXEN_NIC_XGBE:
+   netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x7f);
+   break;
+
+   default:
+   printk(KERN_ERR "%s: Unknown board type\n",
+  netxen_nic_driver_name);
+   result = -1;
+   }
+
+   return result;
+}
+
+long netxen_nic_clear_phy_interrupts(struct netxen_adapter *adapter,
+long portno)
+{
+   long result = 0;
+
+   switch (adapter->ahw.board_type) {
+   case NETXEN_NIC_GBE:
+   result = netxen_niu_gbe_clear_phy_interrupts(adapter, portno);
+   break;
+
+   case NETXEN_NIC_XGBE:
+   netxen_crb_writelit_adapter(adapter, NETXEN_NIU_ACTIVE_INT, -1);
+   break;
+
+   default:
+   printk(KERN_ERR "%s: Unknown board type\n",
+  netxen_nic_driver_name);
+   result = -1;
+   }
+
+   return result;
+}
+
+void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno,
+u32 link)
+{
+   struct netxen_port *pport = adapter->port[portno];
+   struct net_device *netdev = pport->netdev;
+
+   if (link)
+   netif_carrier_on(netdev);
+   else
+   netif_car

[PATCH 2.6.17 3/9] NetXen: hw initialization routines

2006-08-18 Thread Amit S. Kale

diff -Nrup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/netxen/netxen_nic_init.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_init.c
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_init.c  1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_init.c   2006-08-17 
07:12:34.0 -0700
@@ -0,0 +1,1090 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * Source file for NIC routines to initialize the Phantom Hardware
+ *
+ */
+
+#include 
+#include 
+#include "netxen_nic.h"
+#include "netxen_nic_hw.h"
+#include "netxen_nic_ioctl.h"
+#include "netxen_nic_phan_reg.h"
+
+struct crb_addr_pair {
+   long addr;
+   long data;
+};
+
+#define NETXEN_MAX_CRB_XFORM 60
+static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM];
+#define NETXEN_ADDR_ERROR ((unsigned long ) 0x )
+
+#define crb_addr_transform(name) \
+   crb_addr_xform[NETXEN_HW_PX_MAP_CRB_##name] = \
+   NETXEN_HW_CRB_HUB_AGT_ADR_##name << 20
+
+static void crb_addr_transform_setup(void)
+{
+   crb_addr_transform(XDMA);
+   crb_addr_transform(TIMR);
+   crb_addr_transform(SRE);
+   crb_addr_transform(SQN3);
+   crb_addr_transform(SQN2);
+   crb_addr_transform(SQN1);
+   crb_addr_transform(SQN0);
+   crb_addr_transform(SQS3);
+   crb_addr_transform(SQS2);
+   crb_addr_transform(SQS1);
+   crb_addr_transform(SQS0);
+   crb_addr_transform(RPMX7);
+   crb_addr_transform(RPMX6);
+   crb_addr_transform(RPMX5);
+   crb_addr_transform(RPMX4);
+   crb_addr_transform(RPMX3);
+   crb_addr_transform(RPMX2);
+   crb_addr_transform(RPMX1);
+   crb_addr_transform(RPMX0);
+   crb_addr_transform(ROMUSB);
+   crb_addr_transform(SN);
+   crb_addr_transform(QMN);
+   crb_addr_transform(QMS);
+   crb_addr_transform(PGNI);
+   crb_addr_transform(PGND);
+   crb_addr_transform(PGN3);
+   crb_addr_transform(PGN2);
+   crb_addr_transform(PGN1);
+   crb_addr_transform(PGN0);
+   crb_addr_transform(PGSI);
+   crb_addr_transform(PGSD);
+   crb_addr_transform(PGS3);
+   crb_addr_transform(PGS2);
+   crb_addr_transform(PGS1);
+   crb_addr_transform(PGS0);
+   crb_addr_transform(PS);
+   crb_addr_transform(PH);
+   crb_addr_transform(NIU);
+   crb_addr_transform(I2Q);
+   crb_addr_transform(EG);
+   crb_addr_transform(MN);
+   crb_addr_transform(MS);
+   crb_addr_transform(CAS2);
+   crb_addr_transform(CAS1);
+   crb_addr_transform(CAS0);
+   crb_addr_transform(CAM);
+   crb_addr_transform(C2C1);
+   crb_addr_transform(C2C0);
+}
+
+int init_firmware(struct netxen_adapter *adapter)
+{
+   u32 state = 0, loops = 0, err = 0;
+
+   /* Window 1 call */
+   state = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
+
+   if(state == PHAN_INITIALIZE_ACK)
+   return 0;
+
+   while (state != PHAN_INITIALIZE_COMPLETE && loops < 2000) {
+   udelay(100);
+   /* Window 1 call */
+   state = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
+
+   loops++;
+   }
+   if (loops >= 2000) {
+   printk(KERN_ERR "Cmd Peg initialization not complete:%x.\n",
+  state);
+   err = -EIO;
+   return err;
+   }
+   /* Window 1 call */
+   writel(PHAN_INITIALIZE_ACK,
+  NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
+
+   return err;
+}
+
+void initialize_adapter_sw(struct netxen_adapter *adapter)
+{
+   int ctxid, ring;
+   u32 i;
+   u32 num_rx_bufs = 0;
+   struct netxen_rcv_desc_ctx *rcv_desc;
+
+   DPRINTK(INFO, "initializing some queues: %p\n", adapter);
+   for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) {
+   for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
+   struct netxen_rx_buffer *r

[PATCH 2.6.17 2/9] NetXen: Hardware access routines

2006-08-18 Thread Amit S. Kale

diff -Nrup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/netxen/netxen_nic_hw.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_hw.c1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c 2006-08-17 
07:12:34.0 -0700
@@ -0,0 +1,1097 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * Source file for NIC routines to access the Phantom hardware
+ *
+ */
+
+#include "netxen_nic.h"
+#include "netxen_nic_hw.h"
+#include "netxen_nic_phan_reg.h"
+
+/*  PCI Windowing for DDR regions.  */
+
+#define ADDR_IN_RANGE(addr, low, high) \
+   (((addr) <= (high)) && ((addr) >= (low)))
+
+#define NETXEN_FLASH_BASE  (BOOTLD_START)
+#define NETXEN_PHANTOM_MEM_BASE(NETXEN_FLASH_BASE)
+#define NETXEN_MAX_MTU 8000
+#define NETXEN_MTU_MASK0x
+#define NETXEN_WINDOW_ONE 0x200/* CRB Window: bit 25 of CRB address */
+
+unsigned long netxen_nic_pci_set_window(void __iomem * pci_base,
+  unsigned long long addr);
+void netxen_free_hw_resources(struct netxen_adapter *adapter);
+
+int netxen_nic_set_mac(struct net_device *netdev, void *p)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct sockaddr *addr = p;
+
+   if (netif_running(netdev))
+   return -EBUSY;
+
+   if (!is_valid_ether_addr(addr->sa_data))
+   return -EADDRNOTAVAIL;
+
+   DPRINTK(INFO, "valid ether addr\n");
+   memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
+
+   netxen_nic_macaddr_set(port, addr->sa_data);
+
+   return 0;
+}
+
+/**
+ * netxen_nic_set_multi - Multicast
+ **/
+void netxen_nic_set_multi(struct net_device *netdev)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct dev_mc_list *mc_ptr;
+
+   mc_ptr = netdev->mc_list;
+   if (netdev->flags & IFF_PROMISC)
+   netxen_nic_set_promisc_mode(port);
+   else
+   netxen_nic_unset_promisc_mode(port);
+}
+
+/*
+ * netxen_nic_change_mtu - Change the Maximum Transfer Unit
+ * @returns 0 on success, negative on failure
+ */
+int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+
+   if (new_mtu & NETXEN_MTU_MASK)
+   return -EINVAL;
+
+   if (new_mtu > NETXEN_MAX_MTU) {
+   printk(KERN_ERR "%s: %s MTU > NETXEN_MAX_MTU is not 
supported\n",
+  netxen_nic_driver_name, netdev->name);
+   return -EINVAL;
+   }
+
+   netxen_nic_set_mtu(port, new_mtu);
+   netdev->mtu = new_mtu;
+
+   return 0;
+}
+/*
+ * check if the firmware has been downloaded and ready to run  and
+ * setup the address for the descriptors in the adapter
+ */
+int netxen_nic_hw_resources(struct netxen_adapter *adapter)
+{
+   struct netxen_hardware_context *hw = &adapter->ahw;
+   int i;
+   u32 state = 0;
+   void *addr;
+   int loops = 0, err = 0;
+   int ctx, ring;
+   u32 card_cmdring = 0;
+   struct netxen_rcv_desc_crb *rcv_desc_crb = NULL;
+   struct netxen_recv_context *recv_ctx;
+   struct netxen_rcv_desc_ctx *rcv_desc;
+   struct cmd_desc_type0_t *pcmd;
+
+   DPRINTK(INFO, "pci_base: %lx\n", adapter->ahw.pci_base);
+   DPRINTK(INFO, "crb_base: %lx %lx", NETXEN_PCI_CRBSPACE,
+   adapter->ahw.pci_base + NETXEN_PCI_CRBSPACE);
+   DPRINTK(INFO, "cam base: %lx %lx", NETXEN_CRB_CAM,
+   adapter->ahw.pci_base + NETXEN_CRB_CAM);
+   DPRINTK(INFO, "cam RAM: %lx %lx", NETXEN_CAM_RAM_BASE,
+   adapter->ahw.pci_base + NETXEN_CAM_RAM_BASE);
+   DPRINTK(INFO, "NIC base:%lx %lx\n", NIC_CRB_BASE_PORT1,
+   adapter->ahw.pci_base + NIC_CRB_BASE_PORT1);
+
+   /* Window 1 call */
+   card_cmdring = readl(NETXEN_CRB_NORMALIZE(adapt

[PATCH 2.6.17 1/9] NetXen: Makefile and driver main file

2006-08-18 Thread Amit S. Kale

diff -Nrup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/MAINTAINERS linux-2.6.17/MAINTAINERS
--- linux-2.6.17.orig/MAINTAINERS   2006-07-05 01:16:07.0 -0700
+++ linux-2.6.17/MAINTAINERS2006-08-18 02:40:30.0 -0700
@@ -1987,6 +1987,13 @@ L:   netdev@vger.kernel.org
 T: git kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6.git
 S: Maintained

+NETXEN (1/10) GbE SUPPORT
+P: Amit S. Kale
+M: [EMAIL PROTECTED]
+L: netdev@vger.kernel.org
+W: http://www.netxen.com
+S: Supported
+
 IPVS
 P: Wensong Zhang
 M: [EMAIL PROTECTED]
diff -Nrup -X linux-2.6.17.orig/Documentation/dontdiff 
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.0 
-0700
+++ linux-2.6.17/drivers/net/Kconfig2006-07-05 01:18:13.0 -0700
@@ -2311,6 +2311,11 @@ config S2IO_NAPI

  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 -Nrup -X linux-2.6.17.orig/Documentation/dontdiff 
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.0 
-0700
+++ linux-2.6.17/drivers/net/Makefile   2006-07-05 01:18:40.0 -0700
@@ -213,3 +213,4 @@ obj-$(CONFIG_NETCONSOLE) += netconsole.o

 obj-$(CONFIG_FS_ENET) += fs_enet/

+obj-$(CONFIG_NETXEN_NIC) += netxen/
diff -Nrup -X linux-2.6.17.orig/Documentation/dontdiff 
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.0 -0800
+++ linux-2.6.17/drivers/net/netxen/Makefile2006-08-17 07:12:34.0 
-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:

+#[EMAIL PROTECTED]
+# 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 -Nrup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/netxen/netxen_nic_main.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_main.c
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_main.c  1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_main.c   2006-08-17 
07:12:34.0 -0700
@@ -0,0 +1,1107 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ *  Main source file for NetXen NIC Driver on Linux
+ *
+ */
+
+#include "netxen_nic_hw.h"
+
+#include "netxen_nic.h"
+#define DEFINE_GLOBAL_RECV_CRB
+#include "netxen_nic_phan_reg.h"
+#include "netxen_nic_ioctl.h"
+
+MODULE_DESCRIPTION("NetXen Multi port (1

[PATCH 2.6.17 0/9] NetXen: 1G/10G Ethernet Driver

2006-08-18 Thread Amit S. Kale

Hi,

I'll be sending a NetXen Multi port 1G/10G ethernet driver patch in 
subsequent emails. This set of patches have changes as per the 
suggestions, which we received since last post.


Kindly review it and feel free to send feedback.

Thanks,
-Amit

Signed-off-by: Amit S. Kale <[EMAIL PROTECTED]>

 MAINTAINERS  |7
 drivers/net/Kconfig  |5
 drivers/net/Makefile |1
 drivers/net/netxen/Makefile  |   35
 drivers/net/netxen/netxen_nic.h  |  901 +
 drivers/net/netxen/netxen_nic_ethtool.c  |  696 +++
 drivers/net/netxen/netxen_nic_hdr.h  |  611 +
 drivers/net/netxen/netxen_nic_hw.c   | 1097 ++
 drivers/net/netxen/netxen_nic_hw.h   |  500 ++
 drivers/net/netxen/netxen_nic_init.c | 1090 ++
 drivers/net/netxen/netxen_nic_ioctl.h|   75 ++
 drivers/net/netxen/netxen_nic_isr.c  |  300 
 drivers/net/netxen/netxen_nic_main.c | 1107 +++
 drivers/net/netxen/netxen_nic_niu.c  |  778 +
 drivers/net/netxen/netxen_nic_phan_reg.h |  195 +
 15 files changed, 7398 insertions(+)
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2.6.17 9/9] NetXen: niu handling and CRB reg definitions

2006-07-05 Thread Linsys Contractor Amit S. Kale

diff -Naru linux-2.6.17.orig/drivers/net/netxen/netxen_nic_niu.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_niu.c
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_niu.c   1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_niu.c2006-07-05 
01:18:40.369906036 -0700
@@ -0,0 +1,761 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * Provides access to the Network Interface Unit h/w block.
+ *
+ */
+
+#include "netxen_nic.h"
+#include 
+
+/** 
+ * netxen_niu_gbe_phy_read - read a register from the GbE PHY via

+ * mii management interface.
+ *
+ * Note: The MII management interface goes through port 0.
+ *   Individual phys are addressed as follows:
+ * @param phy  [15:8]  phy id
+ * @param reg  [7:0]   register number
+ *
+ * @returns  0 on success
+ *  -1 on error
+ *
+ **/
+long netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy,
+long reg, netxen_crbword_t * readval)
+{
+   long timeout = 0;
+   long result = 0;
+   long restore = 0;
+   struct netxen_niu_gb_mii_mgmt_address address;
+   struct netxen_niu_gb_mii_mgmt_command command;
+   struct netxen_niu_gb_mii_mgmt_indicators status;
+   struct netxen_niu_gb_mii_mgmt_config mii_cfg;
+   struct netxen_niu_gb_mac_config_0_t mac_cfg0;
+
+   /* MII mgmt all goes through port 0 MAC interface, so it cannot be in 
reset */
+   if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0),
+ &mac_cfg0, 4))
+   return -EIO;
+   if (mac_cfg0.soft_reset) {
+   struct netxen_niu_gb_mac_config_0_t temp;
+   *(netxen_crbword_t *) & temp = 0;
+   temp.tx_reset_pb = 1;
+   temp.rx_reset_pb = 1;
+   temp.tx_reset_mac = 1;
+   temp.rx_reset_mac = 1;
+   if (netxen_nic_hw_write_wx(adapter,
+  NETXEN_NIU_GB_MAC_CONFIG_0(0),
+  &temp, 4))
+   return -EIO;
+   restore = 1;
+   }
+
+   /* reset MII management interface */
+   *(netxen_crbword_t *) & mii_cfg = 0;
+   mii_cfg.clockselect = 7;
+   mii_cfg.reset = 1;
+   if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_CONFIG(0),
+  &mii_cfg, 4))
+   return -EIO;
+   mii_cfg.reset = 0;
+   if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_CONFIG(0),
+  &mii_cfg, 4))
+   return -EIO;
+
+   *(netxen_crbword_t *) & address = 0;
+   address.reg_addr = reg;
+   address.phy_addr = phy;
+   if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0),
+  &address, 4))
+   return -EIO;
+   *(netxen_crbword_t *) & command = 0;/* turn off any prior 
activity */
+   if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
+  &command, 4))
+   return -EIO;
+   /* send read command */
+   command.read_cycle = 1;
+   if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
+  &command, 4))
+   return -EIO;
+
+   *(netxen_crbword_t *) & status = 0;
+   do {
+   if (netxen_nic_hw_read_wx(adapter,
+ NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
+ &status, 4))
+   return -EIO;
+   timeout++;
+   } while ((status.busy || status.notvalid)
+&& (timeout++ < NETXEN_NIU_PHY_WAITMAX));
+
+   if (timeout < NETXEN_NIU_PHY_WAITMAX) {
+   if (netxen_nic_hw_read_wx(adapter,
+ NETXEN_NIU_GB_MII_MGMT_STATUS(0),
+  

[PATCH 2.6.17 7/9] NetXen: ioctl interface and intr routines

2006-07-05 Thread Linsys Contractor Amit S. Kale

diff -Naru linux-2.6.17.orig/drivers/net/netxen/netxen_nic_ioctl.h 
linux-2.6.17/drivers/net/netxen/netxen_nic_ioctl.h
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_ioctl.h 1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_ioctl.h  2006-07-05 
01:18:40.360907880 -0700
@@ -0,0 +1,75 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#ifndef __NETXEN_NIC_IOCTL_H__
+#define __NETXEN_NIC_IOCTL_H__
+
+#include 
+
+#define NETXEN_CMD_STARTSIOCDEVPRIVATE
+#define NETXEN_NIC_CMD  (NETXEN_CMD_START + 1)
+#define NETXEN_NIC_NAME (NETXEN_CMD_START + 2)
+
+typedef enum {
+   netxen_nic_cmd_none = 0,
+   netxen_nic_cmd_pci_read,
+   netxen_nic_cmd_pci_write,
+   netxen_nic_cmd_pci_mem_read,
+   netxen_nic_cmd_pci_mem_write,
+   netxen_nic_cmd_pci_config_read,
+   netxen_nic_cmd_pci_config_write,
+   netxen_nic_cmd_get_stats,
+   netxen_nic_cmd_clear_stats,
+   netxen_nic_cmd_get_version
+} netxen_nic_ioctl_cmd_t;
+
+struct netxen_nic_ioctl_data {
+   u32 cmd;
+   u32 unused1;
+   u64 off;
+   u32 size;
+   u32 rv;
+   char u[64];
+   void *ptr;
+};
+
+struct netxen_statistics {
+   u64 rx_packets;
+   u64 tx_packets;
+   u64 rx_bytes;
+   u64 rx_errors;
+   u64 tx_bytes;
+   u64 tx_errors;
+   u64 rx_crc_errors;
+   u64 rx_short_length_error;
+   u64 rx_long_length_error;
+   u64 rx_mac_errors;
+};
+
+#endif /* __NETXEN_NIC_IOCTL_H_ */
diff -Naru linux-2.6.17.orig/drivers/net/netxen/netxen_nic_isr.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_isr.c
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_isr.c   1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_isr.c2006-07-05 
01:18:40.367906446 -0700
@@ -0,0 +1,430 @@
+/*
+ * 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:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#include 
+#include 
+
+#include "netxen_nic.h"
+#include "netxen_nic_hw.h"
+#include "netxen_nic_phan_reg.h"
+
+/*
+ * This will be called when all the ports of the adapter are removed.
+ * This will cleanup and disable interrupts and irq.
+ */
+void netxen_nic_down(struct netxen_port *port)
+{
+   struct netxen_adapter *adapter = port->adapter;
+   int i, j, ctxid;
+   struct netxen_cmd_buffer *cmd_buff;
+   struct netxen_skb_frag *buffrag;
+   struct netxen_ring_context *ctx;
+
+   /* disable phy_ints */
+   netxen_nic_disable_phy_interrupts(adapter, (long)port->portnum);
+
+   adapter->active_ports--;
+
+   if (!adapter->active_ports) {
+   read_lock(&adapter->adapter_lock);
+   netxen_nic_disable_int(adapter);
+   read_unlock(&adapter->adapter_lock);
+
+   for (ctxid = 0; ctxid < MAX_RING_CTX; ++ctxid) {
+   ctx = &adapter->ring_ctx[ctxid];
+   cmd_buff = ctx->cmd_buf_arr;
+
+   f

  1   2   >