Re: [patch 5/7] netxen: fix race in interrupt / napi

2008-01-14 Thread Dhananjay Phadke
Ok, I will respin the failed patches.

Thanks,
-Dhananjay

On Sat, 12 Jan 2008, Jeff Garzik wrote:

 patch conflicted with
 
 commit 1706287f6eb58726a9a0e5cbbde87f49757615e3
 Author: David S. Miller [EMAIL PROTECTED]
 Date:   Mon Jan 7 20:51:29 2008 -0800
 
 [NETXEN]: Fix -poll() done logic.
 
 If work_done = budget we should always elide the NAPI
 completion.
 
 Signed-off-by: David S. Miller [EMAIL PROTECTED]
 
 
--
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: [2.6 patch] drivers/net/netxen/: cleanups

2007-11-08 Thread Dhananjay Phadke
This looks good to me, I might chop off these #if 0 'ed functions in
my next round of patches.

Acked-by: Dhananjay Phadke [EMAIL PROTECTED]

On 11/5/07, Adrian Bunk [EMAIL PROTECTED] wrote:
 This patch contains the following cleanups:
 - static functions in .c files shouldn't be marked inline
 - make needlessly global code static
 - #if 0 unused code

 Signed-off-by: Adrian Bunk [EMAIL PROTECTED]

 ---

  drivers/net/netxen/netxen_nic.h  |   14 
  drivers/net/netxen/netxen_nic_hw.c   |   19 +++---
  drivers/net/netxen/netxen_nic_hw.h   |8 --
  drivers/net/netxen/netxen_nic_init.c |   70 ---
  drivers/net/netxen/netxen_nic_isr.c  |7 +-
  drivers/net/netxen/netxen_nic_main.c |9 +-
  drivers/net/netxen/netxen_nic_niu.c  |   26 +---
  drivers/net/netxen/netxen_nic_phan_reg.h |7 --
  8 files changed, 76 insertions(+), 84 deletions(-)

 dbc7aeed37e41cd37a01cce259e5c0ab01f8dd88
 diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
 index fbc2553..ef9f986 100644
 --- a/drivers/net/netxen/netxen_nic.h
 +++ b/drivers/net/netxen/netxen_nic.h
 @@ -1015,14 +1015,8 @@ int netxen_niu_xgbe_enable_phy_interrupts(struct 
 netxen_adapter *adapter);
  int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter);
  int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter);
  int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter *adapter);
 -int netxen_niu_xgbe_clear_phy_interrupts(struct netxen_adapter *adapter);
 -int netxen_niu_gbe_clear_phy_interrupts(struct netxen_adapter *adapter);
  void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter);
  void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter);
 -void netxen_niu_gbe_set_mii_mode(struct netxen_adapter *adapter, int port,
 -long enable);
 -void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter *adapter, int port,
 - long enable);
  int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
 __u32 * readval);
  int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter,
 @@ -1045,7 +1039,6 @@ 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_erase_pxe(struct netxen_adapter *adapter);

  /* Functions from netxen_nic_init.c */
  void netxen_free_adapter_offload(struct netxen_adapter *adapter);
 @@ -1064,15 +1057,10 @@ 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);
 -int netxen_do_rom_se(struct netxen_adapter *adapter, int addr);

  /* Functions from netxen_nic_isr.c */
  int netxen_nic_link_ok(struct netxen_adapter *adapter);
 -void netxen_nic_isr_other(struct netxen_adapter *adapter);
 -void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 link);
 -void netxen_handle_port_int(struct netxen_adapter *adapter, u32 enable);
  void netxen_initialize_adapter_sw(struct netxen_adapter *adapter);
  void netxen_initialize_adapter_hw(struct netxen_adapter *adapter);
  void *netxen_alloc(struct pci_dev *pdev, size_t sz, dma_addr_t * ptr,
 @@ -1089,8 +1077,6 @@ int netxen_nic_tx_has_work(struct netxen_adapter 
 *adapter);
  void netxen_watchdog_task(struct work_struct *work);
  void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx,
 u32 ringid);
 -void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, u32 ctx,
 -u32 ringid);
  int netxen_process_cmd_ring(unsigned long data);
  u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int 
 max);
  void netxen_nic_set_multi(struct net_device *netdev);
 diff --git a/drivers/net/netxen/netxen_nic_hw.c 
 b/drivers/net/netxen/netxen_nic_hw.c
 index 2c19b8d..b2c7861 100644
 --- a/drivers/net/netxen/netxen_nic_hw.c
 +++ b/drivers/net/netxen/netxen_nic_hw.c
 @@ -33,7 +33,6 @@

  #include netxen_nic.h
  #include netxen_nic_hw.h
 -#define DEFINE_GLOBAL_RECV_CRB
  #include netxen_nic_phan_reg.h


 @@ -244,12 +243,15 @@ struct netxen_recv_crb recv_crb_registers[] = {
 },
  };

 -u64 ctx_addr_sig_regs[][3] = {
 +static u64 ctx_addr_sig_regs[][3] = {
 {NETXEN_NIC_REG(0x188), NETXEN_NIC_REG(0x18c), NETXEN_NIC_REG(0x1c0)},
 {NETXEN_NIC_REG(0x190), NETXEN_NIC_REG(0x194), NETXEN_NIC_REG(0x1c4)},
 {NETXEN_NIC_REG(0x198), NETXEN_NIC_REG(0x19c), NETXEN_NIC_REG(0x1c8)},
 {NETXEN_NIC_REG(0x1a0), NETXEN_NIC_REG(0x1a4), NETXEN_NIC_REG(0x1cc

Re: NetXen driver causing slab corruption in -RT kernels

2007-09-19 Thread Dhananjay Phadke
That 00 0e 1e ... is netxen's mac address, so sounds like the NIC is
dumping a frame in the skb already freed (and poisoned) by the stack.
I suppose -RT kernels preempt the softirq, giving a chance for this race.

The netxen driver doesn't seem to clear the mapped address of the skb in
rx descriptor, instead it replaces it with mapped address of newly
allocated skb. Also, the rx ring is replenished in bursts (at the end of
poll routine), this can help the race if preempted in between.

I am currently reworking the rx handling, hopefully it will fix this.

Thanks for reporting in detail.

-Dhananjay


Vernon Mauery wrote:
 In doing some stress testing of the NetXen driver, I found that my machine 
 was 
 dying in all sorts of weird ways.  I saw several different crashes, BUG 
 messages in the TCP stack and some assert messages in the TCP stack as well.  
 I really didn't think that there could be six different bugs all at once in 
 the TCP/IP stack, so I started looking at possible memory corruption.
 
 I first saw this on 2.6.16-rt22 with a backported netxen driver from 2.6.22.  
 I figured I should try the latest kernel, so I tried it on 2.6.23-rc6-git7 
 but could not trigger the slab corruption messages with CONFIG_DEBUG_SLAB, so 
 I figured the race must only exist in the -RT kernels.  Next I tried 
 2.6.23-rc6-git7-rt1 (I applied patch-2.6.23-rc4-rt1 patch to 2.6.23-rc6-git7 
 and fixed the 5 failing hunks).  After an hour or so, lots of slab corruption 
 messages showed up:
 
 Slab corruption: size-2048 start=f40c4670, len=2048
 Slab corruption: size-2048 start=f313cf48, len=2048
 Redzone: 0x9f911029d74e35b/0x9f911029d74e35b.
 Last user: [c0166be4](kfree+0x80/0x95)
 010: 6b 6b 00 0e 1e 00 16 13 00 0e 1e 00 19 3d 08 00
 020: 45 00 05 dc 92 ab 40 00 40 11 8a 5b 0a 02 02 03
 030: 0a 02 02 04 80 0c 80 0d 05 c8 dc 39 00 00 00 00
 040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 Prev obj: start=f313c730, len=2048
 Redzone: 0xd84156c5635688c0/0xd84156c5635688c0.
 Last user: [f8f06186](netxen_post_rx_buffers_nodb+0x62/0x1f0 [netxen_nic])
 000: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
 010: 5a 5a 00 0e 1e 00 16 13 00 0e 1e 00 19 3d 08 00
 Next obj: start=f313d760, len=2048
 Redzone: 0xd84156c5635688c0/0xd84156c5635688c0.
 Last user: [f8f06186](netxen_post_rx_buffers_nodb+0x62/0x1f0 [netxen_nic])
 000: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
 010: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
 Slab corruption: size-2048 start=f395a6f0, len=2048
 Redzone: 0x9f911029d74e35b/0x9f911029d74e35b.
 Last user: [c0166be4](kfree+0x80/0x95)
 010: 6b 6b 00 0e 1e 00 16 13 00 0e 1e 00 19 3d 08 00
 020: 45 00 05 dc 92 ac 40 00 40 11 8a 5a 0a 02 02 03
 030: 0a 02 02 04 80 0c 80 0d 05 c8 dc 39 00 00 00 00
 040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 Next obj: start=f395af08, len=2048
 Redzone: 0xd84156c5635688c0/0xd84156c5635688c0.
 Last user: [f8f06186](netxen_post_rx_buffers_nodb+0x62/0x1f0 [netxen_nic])
 000: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
 010: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
 Redzone: 0x9f911029d74e35b/0x9f911029d74e35b.
 Last user: [c0166be4](kfree+0x80/0x95)
 010: 6b 6b 00 0e 1e 00 16 13 00 0e 1e 00 19 3d 08 00
 020: 45 00 05 dc 92 aa 40 00 40 11 8a 5c 0a 02 02 03
 030: 0a 02 02 04 80 0c 80 0d 05 c8 dc 39 00 00 00 00
 040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 Next obj: start=f40c4e88, len=2048
 Redzone: 0xd84156c5635688c0/0xd84156c5635688c0.
 Last user: [f8f06186](netxen_post_rx_buffers_nodb+0x62/0x1f0 [netxen_nic])
 000: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
 010: 5a 5a 00 0e 1e 00 16 13 00 0e 1e 00 19 3d 08 00
 
 The stress test that I am running is basically a mixed bag of stuff I threw 
 together.  It runs eight concurrent netperf TCP streams and two concurrent 
 UDP streams in both directions, (and on both 10GbE interfaces), ping -f in 
 both directions, some more disk/cpu loads in the background and a little bit 
 of NFS traffic thrown in for good measure.
 
 --Vernon
-
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: ethtool fixes

2007-09-02 Thread Dhananjay Phadke

Resubmitting the patch. 

This patch improves ethtool support for printing correct ring statistics,
segmentation offload status, etc.

Signed-off by: Dhananjay Phadke [EMAIL PROTECTED]

Index: netdev-2.6/drivers/net/netxen/netxen_nic.h
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic.h
+++ netdev-2.6/drivers/net/netxen/netxen_nic.h
@@ -918,7 +918,7 @@ struct netxen_adapter {
u16 link_duplex;
u16 state;
u16 link_autoneg;
-   int rcsum;
+   int rx_csum;
int status;
spinlock_t stats_lock;
 
Index: netdev-2.6/drivers/net/netxen/netxen_nic_ethtool.c
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic_ethtool.c
+++ netdev-2.6/drivers/net/netxen/netxen_nic_ethtool.c
@@ -518,17 +518,17 @@ netxen_nic_get_ringparam(struct net_devi
ring-rx_jumbo_pending = 0;
for (i = 0; i  MAX_RCV_CTX; ++i) {
ring-rx_pending += adapter-recv_ctx[i].
-   rcv_desc[RCV_DESC_NORMAL_CTXID].rcv_pending;
+   rcv_desc[RCV_DESC_NORMAL_CTXID].max_rx_desc_count;
ring-rx_jumbo_pending += adapter-recv_ctx[i].
-   rcv_desc[RCV_DESC_JUMBO_CTXID].rcv_pending;
+   rcv_desc[RCV_DESC_JUMBO_CTXID].max_rx_desc_count;
}
+   ring-tx_pending = adapter-max_tx_desc_count;
 
-   ring-rx_max_pending = adapter-max_rx_desc_count;
-   ring-tx_max_pending = adapter-max_tx_desc_count;
-   ring-rx_jumbo_max_pending = adapter-max_jumbo_rx_desc_count;
+   ring-rx_max_pending = MAX_RCV_DESCRIPTORS;
+   ring-tx_max_pending = MAX_CMD_DESCRIPTORS_HOST;
+   ring-rx_jumbo_max_pending = MAX_JUMBO_RCV_DESCRIPTORS;
ring-rx_mini_max_pending = 0;
ring-rx_mini_pending = 0;
-   ring-rx_jumbo_pending = 0;
 }
 
 static void
@@ -731,6 +731,19 @@ netxen_nic_get_ethtool_stats(struct net_
}
 }
 
+static u32 netxen_nic_get_rx_csum(struct net_device *dev)
+{
+   struct netxen_adapter *adapter = netdev_priv(dev);
+   return adapter-rx_csum;
+}
+
+static int netxen_nic_set_rx_csum(struct net_device *dev, u32 data)
+{
+   struct netxen_adapter *adapter = netdev_priv(dev);
+   adapter-rx_csum = !!data;
+   return 0;
+}
+
 struct ethtool_ops netxen_nic_ethtool_ops = {
.get_settings = netxen_nic_get_settings,
.set_settings = netxen_nic_set_settings,
@@ -755,4 +768,7 @@ struct ethtool_ops netxen_nic_ethtool_op
.get_strings = netxen_nic_get_strings,
.get_stats_count = netxen_nic_get_stats_count,
.get_ethtool_stats = netxen_nic_get_ethtool_stats,
+   .get_rx_csum = netxen_nic_get_rx_csum,
+   .set_rx_csum = netxen_nic_set_rx_csum,
+   .get_ufo = ethtool_op_get_ufo,
 };
Index: netdev-2.6/drivers/net/netxen/netxen_nic_main.c
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic_main.c
+++ netdev-2.6/drivers/net/netxen/netxen_nic_main.c
@@ -408,6 +408,7 @@ netxen_nic_probe(struct pci_dev *pdev, c
/* This will be reset for mezz cards  */
adapter-portnum = pci_func_id;
adapter-status   = ~NETXEN_NETDEV_STATUS;
+   adapter-rx_csum = 1;
 
netdev-open   = netxen_nic_open;
netdev-stop   = netxen_nic_close;
Index: netdev-2.6/drivers/net/netxen/netxen_nic_init.c
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic_init.c
+++ netdev-2.6/drivers/net/netxen/netxen_nic_init.c
@@ -1118,10 +1118,13 @@ netxen_process_rcv(struct netxen_adapter
 
skb = (struct sk_buff *)buffer-skb;
 
-   if (likely(netxen_get_sts_status(desc) == STATUS_CKSUM_OK)) {
+   if (likely(adapter-rx_csum 
+   netxen_get_sts_status(desc) == 
STATUS_CKSUM_OK)) {
adapter-stats.csummed++;
skb-ip_summed = CHECKSUM_UNNECESSARY;
-   }
+   } else
+   skb-ip_summed = CHECKSUM_NONE;
+
skb-dev = netdev;
if (desc_ctx == RCV_DESC_LRO_CTXID) {
/* True length was only available on the last pkt */
-
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 3/3] netxen: ethtool fixes

2007-08-31 Thread Dhananjay Phadke
oops, ok regenerating patch 3 only.

On Fri, 31 Aug 2007, Jeff Garzik wrote:

 [EMAIL PROTECTED] wrote:
  +static int netxen_nic_set_rx_csum(struct net_device *dev, u32 data)
  +{
  +   struct netxen_adapter *adapter = netdev_priv(dev);
  +   adapter-rx_csum = 0;
  +   return 0;
  +}
 
 Bug:  'data' ignored
 
 
 
-
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] netxen: drop redudant spinlock

2007-07-27 Thread Dhananjay Phadke
Some leftover code that makes use of adapter-lock in tx_timeout function,
which resets the interface under this lock. In close() when the workqueue
is flushed, prints the warning about sleeping with interrupts disabled
(when spinlock debug is enabled). The lock was required with private netxen
IOCTLs, which were removed a while ago.

Index: netdev-2.6/drivers/net/netxen/netxen_nic_main.c
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic_main.c
+++ netdev-2.6/drivers/net/netxen/netxen_nic_main.c
@@ -335,7 +335,6 @@ netxen_nic_probe(struct pci_dev *pdev, c
adapter-ahw.pdev = pdev;
adapter-ahw.pci_func  = pci_func_id;
spin_lock_init(adapter-tx_lock);
-   spin_lock_init(adapter-lock);
 
/* remap phys address */
mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */
@@ -1228,15 +1227,12 @@ static void netxen_tx_timeout_task(struc
 {
struct netxen_adapter *adapter = 
container_of(work, struct netxen_adapter, tx_timeout_task);
-   unsigned long flags;
 
printk(KERN_ERR %s %s: transmit timeout, resetting.\n,
   netxen_nic_driver_name, adapter-netdev-name);
 
-   spin_lock_irqsave(adapter-lock, flags);
netxen_nic_close(adapter-netdev);
netxen_nic_open(adapter-netdev);
-   spin_unlock_irqrestore(adapter-lock, flags);
adapter-netdev-trans_start = jiffies;
netif_wake_queue(adapter-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


Re: [PATCH 0/2] netxen: bug fixes for multiport adapters

2007-07-24 Thread Dhananjay Phadke

Jeff,

Any chance of these patches getting committed soon?

Thanks,
-Dhananjay Phadke

On 7/21/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

These patches include fix for problem with 2nd port of multiport adapters
on IBM blades. Also improves interrupt handling for multiport adapters
avoiding interrupt flood after interrupt is down.

Generated against upstream-fixes.

 drivers/net/netxen/netxen_nic.h  |3 +-
 drivers/net/netxen/netxen_nic_main.c |   85 +++---
 2 files changed, 43 insertions(+), 45 deletions(-)

--
-
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


-
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/1] netxen: Load firmware during probe, dma watchdog fix.

2007-07-24 Thread Dhananjay Phadke

Jeff,

You committed old patch, which I had asked to ignore for two newer patches.

[PATCH 1/1] netxen: Load firmware during probe, dma watchdog fix.

is wrong patch that went in, instead please commit:

[PATCH 1/2] netxen: IMEZ multiport card 2nd port issue, dma watchdog fix
[PATCH 2/2] netxen: Fix interrupt handling for multiport adapters

Thanks,
Dhananjay

On 7/25/07, Jeff Garzik [EMAIL PROTECTED] wrote:

[EMAIL PROTECTED] wrote:
 The firmware should be loaded after resetting hardware during PCI probe,
 besides module unload. This fixes issue with 2nd port of multiport adapter
 on powerpc blades. This patch also fixes a bug that PCI resources are not
 freed if dma watchdog shutdown failed. The dma watchdog poll messages
 during module unload are also suppressed.

 Signed-off-by: Dhananjay Phadke [EMAIL PROTECTED]
 Signed-off-by: Milan Bag [EMAIL PROTECTED]
 Signed-off-by: Wen Xiong [EMAIL PROTECTED]

applied


-
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


-
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/1] netxen: Load firmware during probe, dma watchdog fix.

2007-07-20 Thread Dhananjay Phadke
Please ignore this patch. There's one more patch in the series. I will
send them together.

Thanks,
-Dhananjay
-
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: Does the Netxen driver work?

2007-07-09 Thread Dhananjay Phadke
The MSI error wasn't fatal, so it was suppressed in recent fixes for
2.6.22-rc7. The driver in 2.6.21 had many bugs, but I ain't sure if
recent fixes are going to be pulled in Fedora kernel.

-Dhananjay

Ben Greear wrote:
 Hello!
 
 I just got some Netxen 10Gbe CX4 adapters and put them into freshly
 updated Fedora 7 64-bit systems.  So far, I am not having much luck.
 
 Kernel is:  Official F7  2.6.21-1.3228.fc7
 
 NIC:
 01:00.0 Ethernet controller: NetXen Incorporated NXB-10GCX4 10 Gigabit
 Ethernet PCIe Adapter with CX4 copper interface (rev 25)
 
 The motherboard chipset is Intel based (I can provide more info is someone
 cares..but I first wanted to make sure there are no well-known issues.)
 
 Interesting boot messages:
 
 Jul  5 16:15:17 a440-dc kernel: ACPI: PCI Interrupt :01:00.0[A] -
 GSI 16 (level, low) - IRQ 16
 Jul  5 16:15:17 a440-dc kernel: netxen-nic: unable to allocate MSI
 interrupt error
 Jul  5 16:15:17 a440-dc kernel: netxen-nic: XGbE board initialized
 
 Is that MSI error fatal?
 
 The two NICs are connected by a CX4 cable, and from dmesg output, it
 appears
 they have negotiated link properly.
 
 However, I see tx counters incrementing on both sides, but no rx counters.
 
 I will try the latest 22-pre kernel in the meantime, but if anyone has
 any experience getting these NICs to work, I'm interested to know about it.
 
 Thanks,
 Ben
 
-
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: deinline and sparse fix

2007-07-06 Thread Dhananjay Phadke
Yes those functions are large enough to be de-inlined. I would like to
shrink those to functions, by replacing the switch blocks with a simple
macros, since the mask registers are contiguous.

Will repost a patch based on your patch, after a bit of testing.

Thanks,
-Dhananjay

Stephen Hemminger wrote:
 Get rid of dubious casts to (void *) which causes a sparse warning.
 And move largeish function from inline to the one file that uses the code,
 the compiler can then decide to inline it.
 
 Compile tested only.
 
 Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]
 
 ---
  drivers/net/netxen/netxen_nic.h  |  103 
 ---
  drivers/net/netxen/netxen_nic_main.c |   97 
  2 files changed, 97 insertions(+), 103 deletions(-)
 
 --- a/drivers/net/netxen/netxen_nic.h 2007-07-05 14:21:36.0 -0700
 +++ b/drivers/net/netxen/netxen_nic.h 2007-07-05 16:09:01.0 -0700
 @@ -1097,109 +1097,6 @@ int netxen_nic_change_mtu(struct net_dev
  int netxen_nic_set_mac(struct net_device *netdev, void *p);
  struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev);
  
 -static inline void netxen_nic_disable_int(struct netxen_adapter *adapter)
 -{
 - uint32_tmask = 0x7ff;
 - int retries = 32;
 -
 - DPRINTK(1, INFO, Entered ISR Disable \n);
 -
 - switch (adapter-portnum) {
 - case 0:
 - writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_0));
 - break;
 - case 1:
 - writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_1));
 - break;
 - case 2:
 - writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_2));
 - break;
 - case 3:
 - writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_3));
 - break;
 - }
 -
 - if (adapter-intr_scheme != -1 
 - adapter-intr_scheme != INTR_SCHEME_PERPORT) {
 - writel(mask,
 - (void *)(PCI_OFFSET_SECOND_RANGE(adapter, 
 ISR_INT_MASK)));
 - }
 -
 - /* Window = 0 or 1 */
 - if (!(adapter-flags  NETXEN_NIC_MSI_ENABLED)) {
 - do {
 - writel(0x, (void *)
 - (PCI_OFFSET_SECOND_RANGE(adapter, 
 ISR_INT_TARGET_STATUS)));
 - mask = readl((void *)
 - (pci_base_offset(adapter, 
 ISR_INT_VECTOR)));
 - if (!(mask  0x80))
 - break;
 - udelay(10);
 - } while (--retries);
 -
 - if (!retries) {
 - printk(KERN_NOTICE %s: Failed to disable interrupt 
 completely\n,
 - netxen_nic_driver_name);
 - }
 - }
 -
 - DPRINTK(1, INFO, Done with Disable Int\n);
 -
 - return;
 -}
 -
 -static inline void netxen_nic_enable_int(struct netxen_adapter *adapter)
 -{
 - u32 mask;
 -
 - DPRINTK(1, INFO, Entered ISR Enable \n);
 -
 - if (adapter-intr_scheme != -1 
 - adapter-intr_scheme != INTR_SCHEME_PERPORT) {
 - switch (adapter-ahw.board_type) {
 - case NETXEN_NIC_GBE:
 - mask  =  0x77b;
 - break;
 - case NETXEN_NIC_XGBE:
 - mask  =  0x77f;
 - break;
 - default:
 - mask  =  0x7ff;
 - break;
 - }
 -
 - writel(mask,
 - (void *)(PCI_OFFSET_SECOND_RANGE(adapter, 
 ISR_INT_MASK)));
 - }
 - switch (adapter-portnum) {
 - case 0:
 - writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_0));
 - break;
 - case 1:
 - writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_1));
 - break;
 - case 2:
 - writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_2));
 - break;
 - case 3:
 - writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_3));
 - break;
 - }
 -
 - if (!(adapter-flags  NETXEN_NIC_MSI_ENABLED)) {
 - mask = 0xbff;
 - if (adapter-intr_scheme != -1 
 - adapter-intr_scheme != INTR_SCHEME_PERPORT) {
 - writel(0X0, NETXEN_CRB_NORMALIZE(adapter, 
 CRB_INT_VECTOR));
 - }
 - writel(mask,
 - (void *)(PCI_OFFSET_SECOND_RANGE(adapter, 
 ISR_INT_TARGET_MASK)));
 - }
 -
 - DPRINTK(1, INFO, Done with enable Int\n);
 -
 - return;
 -}
  
  /*
   * NetXen Board information
 --- a/drivers/net/netxen/netxen_nic_main.c2007-07-05 15:17:32.0 
 -0700
 +++ b/drivers/net/netxen/netxen_nic_main.c2007-07-05 16:09:59.0 
 -0700
 @@ -156,6 +156,103 @@ static inline void netxen_nic_update_cmd
  #define  ADAPTER_LIST_SIZE 12
  int netxen_cards_found;
  
 

RESEND [PATCH 0/3] NetXen: Bug fixes for multiport and blade adapters

2007-07-01 Thread dhananjay . phadke
Removed signal_pending checks during init, per Jeff's suggestion.


 drivers/net/netxen/netxen_nic.h  |  180 +++---
 drivers/net/netxen/netxen_nic_hdr.h  |2 +
 drivers/net/netxen/netxen_nic_hw.c   |   33 --
 drivers/net/netxen/netxen_nic_init.c |   51 +
 drivers/net/netxen/netxen_nic_main.c |  177 ++---
 drivers/net/netxen/netxen_nic_phan_reg.h |   14 +++
 6 files changed, 341 insertions(+), 116 deletions(-)
-
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


RESEND [PATCH 2/3] NetXen: Support per PCI-function interrupt mask registers

2007-07-01 Thread dhananjay . phadke
This patch updates the various access routines to access different
control and status settings present in different register locations.
This will fix problems related to working of different ports in
multi Port card.

Signed-off by: Dhananjay Phadke [EMAIL PROTECTED]
Signed-off by: Milan Bag [EMAIL PROTECTED]

Index: netdev-2.6/drivers/net/netxen/netxen_nic.h
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic.h
+++ netdev-2.6/drivers/net/netxen/netxen_nic.h
@@ -937,6 +937,7 @@ struct netxen_adapter {
struct netxen_ring_ctx *ctx_desc;
struct pci_dev *ctx_desc_pdev;
dma_addr_t ctx_desc_phys_addr;
+   int intr_scheme;
int (*enable_phy_interrupts) (struct netxen_adapter *);
int (*disable_phy_interrupts) (struct netxen_adapter *);
void (*handle_phy_intr) (struct netxen_adapter *);
@@ -1080,37 +1081,106 @@ struct net_device_stats *netxen_nic_get_
 
 static inline void netxen_nic_disable_int(struct netxen_adapter *adapter)
 {
-   /*
-* ISR_INT_MASK: Can be read from window 0 or 1.
-*/
-   writel(0x7ff, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
+   uint32_tmask = 0x7ff;
+   int retries = 32;
 
+   DPRINTK(1, INFO, Entered ISR Disable \n);
+
+   switch (adapter-portnum) {
+   case 0:
+   writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_0));
+   break;
+   case 1:
+   writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_1));
+   break;
+   case 2:
+   writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_2));
+   break;
+   case 3:
+   writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_3));
+   break;
+   }
+
+   if (adapter-intr_scheme != -1 
+   adapter-intr_scheme != INTR_SCHEME_PERPORT) {
+   writel(mask,
+   (void *)(PCI_OFFSET_SECOND_RANGE(adapter, 
ISR_INT_MASK)));
+   }
+
+   /* Window = 0 or 1 */
+   if (!(adapter-flags  NETXEN_NIC_MSI_ENABLED)) {
+   do {
+   writel(0x, (void *)
+   (PCI_OFFSET_SECOND_RANGE(adapter, 
ISR_INT_TARGET_STATUS)));
+   mask = readl((void *)
+   (pci_base_offset(adapter, 
ISR_INT_VECTOR)));
+   if (!(mask  0x80))
+   break;
+   udelay(10);
+   } while (--retries);
+
+   if (!retries) {
+   printk(KERN_NOTICE %s: Failed to disable interrupt 
completely\n,
+   netxen_nic_driver_name);
+   }
+   }
+
+   DPRINTK(1, INFO, Done with Disable Int\n);
+
+   return;
 }
 
 static inline void netxen_nic_enable_int(struct netxen_adapter *adapter)
 {
u32 mask;
 
-   switch (adapter-ahw.board_type) {
-   case NETXEN_NIC_GBE:
-   mask = 0x77b;
+   DPRINTK(1, INFO, Entered ISR Enable \n);
+
+   if (adapter-intr_scheme != -1 
+   adapter-intr_scheme != INTR_SCHEME_PERPORT) {
+   switch (adapter-ahw.board_type) {
+   case NETXEN_NIC_GBE:
+   mask  =  0x77b;
+   break;
+   case NETXEN_NIC_XGBE:
+   mask  =  0x77f;
+   break;
+   default:
+   mask  =  0x7ff;
+   break;
+   }
+
+   writel(mask,
+   (void *)(PCI_OFFSET_SECOND_RANGE(adapter, 
ISR_INT_MASK)));
+   }
+   switch (adapter-portnum) {
+   case 0:
+   writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_0));
+   break;
+   case 1:
+   writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_1));
break;
-   case NETXEN_NIC_XGBE:
-   mask = 0x77f;
+   case 2:
+   writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_2));
break;
-   default:
-   mask = 0x7ff;
+   case 3:
+   writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_3));
break;
}
 
-   writel(mask, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
-
if (!(adapter-flags  NETXEN_NIC_MSI_ENABLED)) {
mask = 0xbff;
-   writel(0X0, NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR));
-   writel(mask, PCI_OFFSET_SECOND_RANGE(adapter,
-ISR_INT_TARGET_MASK));
+   if (adapter-intr_scheme != -1 
+   adapter-intr_scheme != INTR_SCHEME_PERPORT) {
+   writel(0X0, NETXEN_CRB_NORMALIZE(adapter, 
CRB_INT_VECTOR));
+   }
+   writel

RESEND [PATCH 1/3] NetXen: Fix issue of MSI not working correctly

2007-07-01 Thread dhananjay . phadke
NetXen driver uses PCI function 0 to provide the functionality of MSI.
The patch makes driver check the bus master bit for function 0 and
enable it after the card initialization.

Signed-off-by: Dhananjay Phadke[EMAIL PROTECTED]
Signed-off-by: Milan Bag [EMAIL PROTECTED]
Signed-off-by: Wen Xiong [EMAIL PROTECTED]

Index: netdev-2.6/drivers/net/netxen/netxen_nic_main.c
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic_main.c
+++ netdev-2.6/drivers/net/netxen/netxen_nic_main.c
@@ -336,11 +336,9 @@ netxen_nic_probe(struct pci_dev *pdev, c
if (pci_using_dac)
netdev-features |= NETIF_F_HIGHDMA;
 
-   if (pci_enable_msi(pdev)) {
+   if (pci_enable_msi(pdev))
adapter-flags = ~NETXEN_NIC_MSI_ENABLED;
-   printk(KERN_WARNING %s: unable to allocate MSI interrupt
-   error\n, netxen_nic_driver_name);
-   } else
+   else
adapter-flags |= NETXEN_NIC_MSI_ENABLED;
 
netdev-irq = pdev-irq;
@@ -355,13 +353,6 @@ netxen_nic_probe(struct pci_dev *pdev, c
/* initialize the adapter */
netxen_initialize_adapter_hw(adapter);
 
-#ifdef CONFIG_PPC
-   if ((adapter-ahw.boardcfg.board_type ==
-   NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) 
-   (pci_func_id == 2))
-   goto err_out_free_adapter;
-#endif /* CONFIG_PPC */
-
/*
 *  Adapter in our case is quad port so initialize it before
 *  initializing the ports
@@ -509,16 +500,22 @@ netxen_nic_probe(struct pci_dev *pdev, c
NETXEN_CAM_RAM(0x1fc)));
if (val == 0x) {
/* This is the first boot after power up */
+   netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(0x4), val);
+   if (!(val  0x4)) {
+   val |= 0x4;
+   netxen_nic_write_w0(adapter, NETXEN_PCIE_REG(0x4), val);
+   netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(0x4), val);
+   }
val = readl(NETXEN_CRB_NORMALIZE(adapter,
NETXEN_ROMUSB_GLB_SW_RESET));
printk(KERN_INFONetXen: read 0x%08x for reset reg.\n,val);
if (val != 0x8f) {
/* clear the register for future unloads/loads */
-   writel(0, NETXEN_CRB_NORMALIZE(adapter,
-   NETXEN_CAM_RAM(0x1fc)));
-   printk(KERN_ERR ERROR in NetXen HW init sequence.\n);
-   err = -ENODEV;
-   goto err_out_free_dev;
+   writel(0, NETXEN_CRB_NORMALIZE(adapter,
+   NETXEN_CAM_RAM(0x1fc)));
+   printk(KERN_ERR ERROR in NetXen HW init 
sequence.\n);
+   err = -ENODEV;
+   goto err_out_free_dev;
}
 
/* clear the register for future unloads/loads */

-- 
-
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


RESEND [PATCH 3/3] NetXen: Graceful teardown of interface and hardware upon module unload

2007-07-01 Thread dhananjay . phadke
These changes allow driver close routine to be called during module unload,
to clean-up buffers and other software resources, flush queues etc. Also,
hardware is reset to pristine state. 

Signed-off-by: Dhananjay Phadke [EMAIL PROTECTED]
Signed-off-by: Milan Bag [EMAIL PROTECTED]
Signed-off-by: Wen Xiong [EMAIL PROTECTED]

Index: netdev-2.6/drivers/net/netxen/netxen_nic.h
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic.h
+++ netdev-2.6/drivers/net/netxen/netxen_nic.h
@@ -952,6 +952,24 @@ struct netxen_adapter {
int (*stop_port) (struct netxen_adapter *);
 }; /* netxen_adapter structure */
 
+/*
+ * NetXen dma watchdog control structure
+ *
+ * Bit 0   : enabled = R/O: 1 watchdog active, 0 inactive
+ * Bit 1   : disable_request = 1 req disable dma watchdog
+ * Bit 2   : enable_request =  1 req enable dma watchdog
+ * Bit 3-31: unused
+ */
+
+#define netxen_set_dma_watchdog_disable_req(config_word) \
+   _netxen_set_bits(config_word, 1, 1, 1)
+#define netxen_set_dma_watchdog_enable_req(config_word) \
+   _netxen_set_bits(config_word, 2, 1, 1)
+#define netxen_get_dma_watchdog_enabled(config_word) \
+   ((config_word)  0x1)
+#define netxen_get_dma_watchdog_disabled(config_word) \
+   (((config_word)  1)  0x1)
+
 /* Max number of xmit producer threads that can run simultaneously */
 #defineMAX_XMIT_PRODUCERS  16
 
@@ -1031,8 +1049,8 @@ int netxen_nic_erase_pxe(struct netxen_a
 /* Functions from netxen_nic_init.c */
 void netxen_free_adapter_offload(struct netxen_adapter *adapter);
 int netxen_initialize_adapter_offload(struct netxen_adapter *adapter);
-void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
-void netxen_load_firmware(struct netxen_adapter *adapter);
+int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
+int 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, 
@@ -1234,6 +1252,62 @@ static inline void get_brd_name_by_type(
name = Unknown;
 }
 
+static inline int
+dma_watchdog_shutdown_request(struct netxen_adapter *adapter)
+{
+   u32 ctrl;
+
+   /* check if already inactive */
+   if (netxen_nic_hw_read_wx(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl, 4))
+   printk(KERN_ERR failed to read dma watchdog status\n);
+
+   if (netxen_get_dma_watchdog_enabled(ctrl) == 0)
+   return 1;
+
+   /* Send the disable request */
+   netxen_set_dma_watchdog_disable_req(ctrl);
+   netxen_crb_writelit_adapter(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
+
+   return 0;
+}
+
+static inline int
+dma_watchdog_shutdown_poll_result(struct netxen_adapter *adapter)
+{
+   u32 ctrl;
+
+   if (netxen_nic_hw_read_wx(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl, 4))
+   printk(KERN_ERR failed to read dma watchdog status\n);
+
+   return ((netxen_get_dma_watchdog_enabled(ctrl) == 0) 
+   (netxen_get_dma_watchdog_disabled(ctrl) == 0));
+}
+
+static inline int
+dma_watchdog_wakeup(struct netxen_adapter *adapter)
+{
+   u32 ctrl;
+
+   if (netxen_nic_hw_read_wx(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl, 4))
+   printk(KERN_ERR failed to read dma watchdog status\n);
+
+   if (netxen_get_dma_watchdog_enabled(ctrl))
+   return 1;
+
+   /* send the wakeup request */
+   netxen_set_dma_watchdog_enable_req(ctrl);
+
+   netxen_crb_writelit_adapter(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
+
+   return 0;
+}
+
+
 int netxen_is_flash_supported(struct netxen_adapter *adapter);
 int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]);
 extern void netxen_change_ringparam(struct netxen_adapter *adapter);
Index: netdev-2.6/drivers/net/netxen/netxen_nic_hdr.h
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic_hdr.h
+++ netdev-2.6/drivers/net/netxen/netxen_nic_hdr.h
@@ -687,4 +687,6 @@ enum {
 
 #define PCIE_MAX_MASTER_SPLIT  (0x14048)
 
+#define NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL   (0x14)
+
 #endif /* __NETXEN_NIC_HDR_H_ */
Index: netdev-2.6/drivers/net/netxen/netxen_nic_hw.c
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic_hw.c
+++ netdev-2.6/drivers/net/netxen/netxen_nic_hw.c
@@ -377,7 +377,7 @@ int netxen_nic_hw_resources(struct netxe

RESEND [PATCH 3/3] NetXen: Graceful teardown of interface and hardware upon module unload

2007-07-01 Thread Dhananjay Phadke
Resending patch 3/3 only.

These changes allow driver close routine to be called during module unload,
to clean-up buffers and other software resources, flush queues etc. Also,
hardware is reset to pristine state. 

Signed-off-by: Dhananjay Phadke [EMAIL PROTECTED]
Signed-off-by: Milan Bag [EMAIL PROTECTED]
Signed-off-by: Wen Xiong [EMAIL PROTECTED]

Index: netdev-2.6/drivers/net/netxen/netxen_nic.h
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic.h
+++ netdev-2.6/drivers/net/netxen/netxen_nic.h
@@ -952,6 +952,24 @@ struct netxen_adapter {
int (*stop_port) (struct netxen_adapter *);
 }; /* netxen_adapter structure */
 
+/*
+ * NetXen dma watchdog control structure
+ *
+ * Bit 0   : enabled = R/O: 1 watchdog active, 0 inactive
+ * Bit 1   : disable_request = 1 req disable dma watchdog
+ * Bit 2   : enable_request =  1 req enable dma watchdog
+ * Bit 3-31: unused
+ */
+
+#define netxen_set_dma_watchdog_disable_req(config_word) \
+   _netxen_set_bits(config_word, 1, 1, 1)
+#define netxen_set_dma_watchdog_enable_req(config_word) \
+   _netxen_set_bits(config_word, 2, 1, 1)
+#define netxen_get_dma_watchdog_enabled(config_word) \
+   ((config_word)  0x1)
+#define netxen_get_dma_watchdog_disabled(config_word) \
+   (((config_word)  1)  0x1)
+
 /* Max number of xmit producer threads that can run simultaneously */
 #defineMAX_XMIT_PRODUCERS  16
 
@@ -1031,8 +1049,8 @@ int netxen_nic_erase_pxe(struct netxen_a
 /* Functions from netxen_nic_init.c */
 void netxen_free_adapter_offload(struct netxen_adapter *adapter);
 int netxen_initialize_adapter_offload(struct netxen_adapter *adapter);
-void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
-void netxen_load_firmware(struct netxen_adapter *adapter);
+int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
+int 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, 
@@ -1234,6 +1252,62 @@ static inline void get_brd_name_by_type(
name = Unknown;
 }
 
+static inline int
+dma_watchdog_shutdown_request(struct netxen_adapter *adapter)
+{
+   u32 ctrl;
+
+   /* check if already inactive */
+   if (netxen_nic_hw_read_wx(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl, 4))
+   printk(KERN_ERR failed to read dma watchdog status\n);
+
+   if (netxen_get_dma_watchdog_enabled(ctrl) == 0)
+   return 1;
+
+   /* Send the disable request */
+   netxen_set_dma_watchdog_disable_req(ctrl);
+   netxen_crb_writelit_adapter(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
+
+   return 0;
+}
+
+static inline int
+dma_watchdog_shutdown_poll_result(struct netxen_adapter *adapter)
+{
+   u32 ctrl;
+
+   if (netxen_nic_hw_read_wx(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl, 4))
+   printk(KERN_ERR failed to read dma watchdog status\n);
+
+   return ((netxen_get_dma_watchdog_enabled(ctrl) == 0) 
+   (netxen_get_dma_watchdog_disabled(ctrl) == 0));
+}
+
+static inline int
+dma_watchdog_wakeup(struct netxen_adapter *adapter)
+{
+   u32 ctrl;
+
+   if (netxen_nic_hw_read_wx(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl, 4))
+   printk(KERN_ERR failed to read dma watchdog status\n);
+
+   if (netxen_get_dma_watchdog_enabled(ctrl))
+   return 1;
+
+   /* send the wakeup request */
+   netxen_set_dma_watchdog_enable_req(ctrl);
+
+   netxen_crb_writelit_adapter(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
+
+   return 0;
+}
+
+
 int netxen_is_flash_supported(struct netxen_adapter *adapter);
 int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]);
 extern void netxen_change_ringparam(struct netxen_adapter *adapter);
Index: netdev-2.6/drivers/net/netxen/netxen_nic_hdr.h
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic_hdr.h
+++ netdev-2.6/drivers/net/netxen/netxen_nic_hdr.h
@@ -687,4 +687,6 @@ enum {
 
 #define PCIE_MAX_MASTER_SPLIT  (0x14048)
 
+#define NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL   (0x14)
+
 #endif /* __NETXEN_NIC_HDR_H_ */
Index: netdev-2.6/drivers/net/netxen/netxen_nic_hw.c
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic_hw.c
+++ netdev-2.6/drivers/net/netxen/netxen_nic_hw.c
@@ -377,7 +377,7 @@ int netxen_nic_hw_resources(struct netxe

Re: [PATCH 0/3] NetXen: Updates and bug fixes for NetXen 1/10G driver

2007-06-30 Thread Dhananjay Phadke

There's change of guard from NetXen side. I have reworked Mithlesh's
original patches based on Michael's feedback. Will be sending out shortly.

--
Dhananjay Phadke
NetXen Inc.

On 6/22/07, Mithlesh Thukral [EMAIL PROTECTED] wrote:

Hi All,

I will be sending updates for NetXen NIC 1/10 G Ethernet driver
in the following emails. These are bug fixes and better interrupt
handling schemes. All these patches have been test on x86 machines and
PowerPC blades.

Thanks,
Mithlesh Thukral
-
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


-
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: Bug fixes for multiport and blade adapters

2007-06-30 Thread dhananjay . phadke
Sending reworked patches based on Michael's feedback (originally sent
by Mithlesh Thukral). These patches address interrupt mask issues on 
multiport adapters, as well as stability issues on powerpc blades.

-- 
Dhananjay Phadke
NetXen Inc.

 drivers/net/netxen/netxen_nic.h  |  176 +++---
 drivers/net/netxen/netxen_nic_hdr.h  |2 +
 drivers/net/netxen/netxen_nic_hw.c   |   33 --
 drivers/net/netxen/netxen_nic_init.c |   56 ++
 drivers/net/netxen/netxen_nic_main.c |  176 +++---
 drivers/net/netxen/netxen_nic_phan_reg.h |   14 +++
 6 files changed, 341 insertions(+), 116 deletions(-)
-
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: Fix issue of MSI not working correctly

2007-06-30 Thread dhananjay . phadke
NetXen driver uses PCI function 0 to provide the functionality of MSI.
The patch makes driver check the bus master bit for function 0 and
enable it after the card initialization.

Signed-off-by: Dhananjay Phadke[EMAIL PROTECTED]
Signed-off-by: Milan Bag [EMAIL PROTECTED]
Signed-off-by: Wen Xiong [EMAIL PROTECTED]

Index: netdev-2.6/drivers/net/netxen/netxen_nic_main.c
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic_main.c
+++ netdev-2.6/drivers/net/netxen/netxen_nic_main.c
@@ -336,11 +336,9 @@ netxen_nic_probe(struct pci_dev *pdev, c
if (pci_using_dac)
netdev-features |= NETIF_F_HIGHDMA;
 
-   if (pci_enable_msi(pdev)) {
+   if (pci_enable_msi(pdev))
adapter-flags = ~NETXEN_NIC_MSI_ENABLED;
-   printk(KERN_WARNING %s: unable to allocate MSI interrupt
-   error\n, netxen_nic_driver_name);
-   } else
+   else
adapter-flags |= NETXEN_NIC_MSI_ENABLED;
 
netdev-irq = pdev-irq;
@@ -355,13 +353,6 @@ netxen_nic_probe(struct pci_dev *pdev, c
/* initialize the adapter */
netxen_initialize_adapter_hw(adapter);
 
-#ifdef CONFIG_PPC
-   if ((adapter-ahw.boardcfg.board_type ==
-   NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) 
-   (pci_func_id == 2))
-   goto err_out_free_adapter;
-#endif /* CONFIG_PPC */
-
/*
 *  Adapter in our case is quad port so initialize it before
 *  initializing the ports
@@ -509,16 +500,22 @@ netxen_nic_probe(struct pci_dev *pdev, c
NETXEN_CAM_RAM(0x1fc)));
if (val == 0x) {
/* This is the first boot after power up */
+   netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(0x4), val);
+   if (!(val  0x4)) {
+   val |= 0x4;
+   netxen_nic_write_w0(adapter, NETXEN_PCIE_REG(0x4), val);
+   netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(0x4), val);
+   }
val = readl(NETXEN_CRB_NORMALIZE(adapter,
NETXEN_ROMUSB_GLB_SW_RESET));
printk(KERN_INFONetXen: read 0x%08x for reset reg.\n,val);
if (val != 0x8f) {
/* clear the register for future unloads/loads */
-   writel(0, NETXEN_CRB_NORMALIZE(adapter,
-   NETXEN_CAM_RAM(0x1fc)));
-   printk(KERN_ERR ERROR in NetXen HW init sequence.\n);
-   err = -ENODEV;
-   goto err_out_free_dev;
+   writel(0, NETXEN_CRB_NORMALIZE(adapter,
+   NETXEN_CAM_RAM(0x1fc)));
+   printk(KERN_ERR ERROR in NetXen HW init 
sequence.\n);
+   err = -ENODEV;
+   goto err_out_free_dev;
}
 
/* clear the register for future unloads/loads */

-- 
-
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: Support per PCI-function interrupt mask registers

2007-06-30 Thread dhananjay . phadke
This patch updates the various access routines to access different
control and status settings present in different register locations.
This will fix problems related to working of different ports in
multi Port card.

Signed-off by: Dhananjay Phadke [EMAIL PROTECTED]
Signed-off by: Milan Bag [EMAIL PROTECTED]

Index: netdev-2.6/drivers/net/netxen/netxen_nic.h
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic.h
+++ netdev-2.6/drivers/net/netxen/netxen_nic.h
@@ -937,6 +937,7 @@ struct netxen_adapter {
struct netxen_ring_ctx *ctx_desc;
struct pci_dev *ctx_desc_pdev;
dma_addr_t ctx_desc_phys_addr;
+   int intr_scheme;
int (*enable_phy_interrupts) (struct netxen_adapter *);
int (*disable_phy_interrupts) (struct netxen_adapter *);
void (*handle_phy_intr) (struct netxen_adapter *);
@@ -1080,37 +1081,102 @@ struct net_device_stats *netxen_nic_get_
 
 static inline void netxen_nic_disable_int(struct netxen_adapter *adapter)
 {
-   /*
-* ISR_INT_MASK: Can be read from window 0 or 1.
-*/
-   writel(0x7ff, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
+   uint32_tmask = 0x7ff;
+   int count = 0;
 
+   DPRINTK(1, INFO, Entered ISR Disable \n);
+
+   switch (adapter-portnum) {
+   case 0:
+   writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_0));
+   break;
+   case 1:
+   writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_1));
+   break;
+   case 2:
+   writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_2));
+   break;
+   case 3:
+   writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_3));
+   break;
+   }
+
+   if (adapter-intr_scheme != -1 
+   adapter-intr_scheme != INTR_SCHEME_PERPORT) {
+   writel(mask,
+   (void *)(PCI_OFFSET_SECOND_RANGE(adapter, 
ISR_INT_MASK)));
+   }
+
+   /* Window = 0 or 1 */
+   if (!(adapter-flags  NETXEN_NIC_MSI_ENABLED)) {
+   do {
+   writel(0x, (void *)
+   (PCI_OFFSET_SECOND_RANGE(adapter, 
ISR_INT_TARGET_STATUS)));
+   mask = readl((void *)
+   (pci_base_offset(adapter, 
ISR_INT_VECTOR)));
+   } while (((mask  0x80) != 0)  (++count  32));
+
+   if ((mask  0x80) != 0) {
+   printk(KERN_NOTICE Could not disable interrupt 
completely\n);
+   }
+   }
+
+   DPRINTK(1, INFO, Done with Disable Int\n);
+
+   return;
 }
 
 static inline void netxen_nic_enable_int(struct netxen_adapter *adapter)
 {
u32 mask;
 
-   switch (adapter-ahw.board_type) {
-   case NETXEN_NIC_GBE:
-   mask = 0x77b;
+   DPRINTK(1, INFO, Entered ISR Enable \n);
+
+   if (adapter-intr_scheme != -1 
+   adapter-intr_scheme != INTR_SCHEME_PERPORT) {
+   switch (adapter-ahw.board_type) {
+   case NETXEN_NIC_GBE:
+   mask  =  0x77b;
+   break;
+   case NETXEN_NIC_XGBE:
+   mask  =  0x77f;
+   break;
+   default:
+   mask  =  0x7ff;
+   break;
+   }
+
+   writel(mask,
+   (void *)(PCI_OFFSET_SECOND_RANGE(adapter, 
ISR_INT_MASK)));
+   }
+   switch (adapter-portnum) {
+   case 0:
+   writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_0));
+   break;
+   case 1:
+   writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_1));
break;
-   case NETXEN_NIC_XGBE:
-   mask = 0x77f;
+   case 2:
+   writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_2));
break;
-   default:
-   mask = 0x7ff;
+   case 3:
+   writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_3));
break;
}
 
-   writel(mask, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
-
if (!(adapter-flags  NETXEN_NIC_MSI_ENABLED)) {
mask = 0xbff;
-   writel(0X0, NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR));
-   writel(mask, PCI_OFFSET_SECOND_RANGE(adapter,
-ISR_INT_TARGET_MASK));
+   if (adapter-intr_scheme != -1 
+   adapter-intr_scheme != INTR_SCHEME_PERPORT) {
+   writel(0X0, NETXEN_CRB_NORMALIZE(adapter, 
CRB_INT_VECTOR));
+   }
+   writel(mask,
+   (void *)(PCI_OFFSET_SECOND_RANGE(adapter, 
ISR_INT_TARGET_MASK)));
}
+
+   DPRINTK(1, INFO, Done with enable Int\n

[PATCH 3/3] NetXen: Graceful teardown of interface and hardware upon module unload

2007-06-30 Thread dhananjay . phadke
These changes allow driver close routine to be called during module unload,
to clean-up buffers and other software resources, flush queues etc. Also,
hardware is reset to pristine state. 

Signed-off-by: Dhananjay Phadke [EMAIL PROTECTED]
Signed-off-by: Milan Bag [EMAIL PROTECTED]
Signed-off-by: Wen Xiong [EMAIL PROTECTED]

Index: netdev-2.6/drivers/net/netxen/netxen_nic.h
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic.h
+++ netdev-2.6/drivers/net/netxen/netxen_nic.h
@@ -952,6 +952,24 @@ struct netxen_adapter {
int (*stop_port) (struct netxen_adapter *);
 }; /* netxen_adapter structure */
 
+/*
+ * NetXen dma watchdog control structure
+ *
+ * Bit 0   : enabled = R/O: 1 watchdog active, 0 inactive
+ * Bit 1   : disable_request = 1 req disable dma watchdog
+ * Bit 2   : enable_request =  1 req enable dma watchdog
+ * Bit 3-31: unused
+ */
+
+#define netxen_set_dma_watchdog_disable_req(config_word) \
+   _netxen_set_bits(config_word, 1, 1, 1)
+#define netxen_set_dma_watchdog_enable_req(config_word) \
+   _netxen_set_bits(config_word, 2, 1, 1)
+#define netxen_get_dma_watchdog_enabled(config_word) \
+   ((config_word)  0x1)
+#define netxen_get_dma_watchdog_disabled(config_word) \
+   (((config_word)  1)  0x1)
+
 /* Max number of xmit producer threads that can run simultaneously */
 #defineMAX_XMIT_PRODUCERS  16
 
@@ -1031,8 +1049,8 @@ int netxen_nic_erase_pxe(struct netxen_a
 /* Functions from netxen_nic_init.c */
 void netxen_free_adapter_offload(struct netxen_adapter *adapter);
 int netxen_initialize_adapter_offload(struct netxen_adapter *adapter);
-void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
-void netxen_load_firmware(struct netxen_adapter *adapter);
+int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
+int 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, 
@@ -1230,6 +1248,62 @@ static inline void get_brd_name_by_type(
name = Unknown;
 }
 
+static inline int
+dma_watchdog_shutdown_request(struct netxen_adapter *adapter)
+{
+   u32 ctrl;
+
+   /* check if already inactive */
+   if (netxen_nic_hw_read_wx(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl, 4))
+   printk(KERN_ERR failed to read dma watchdog status\n);
+
+   if (netxen_get_dma_watchdog_enabled(ctrl) == 0)
+   return 1;
+
+   /* Send the disable request */
+   netxen_set_dma_watchdog_disable_req(ctrl);
+   netxen_crb_writelit_adapter(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
+
+   return 0;
+}
+
+static inline int
+dma_watchdog_shutdown_poll_result(struct netxen_adapter *adapter)
+{
+   u32 ctrl;
+
+   if (netxen_nic_hw_read_wx(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl, 4))
+   printk(KERN_ERR failed to read dma watchdog status\n);
+
+   return ((netxen_get_dma_watchdog_enabled(ctrl) == 0) 
+   (netxen_get_dma_watchdog_disabled(ctrl) == 0));
+}
+
+static inline int
+dma_watchdog_wakeup(struct netxen_adapter *adapter)
+{
+   u32 ctrl;
+
+   if (netxen_nic_hw_read_wx(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl, 4))
+   printk(KERN_ERR failed to read dma watchdog status\n);
+
+   if (netxen_get_dma_watchdog_enabled(ctrl))
+   return 1;
+
+   /* send the wakeup request */
+   netxen_set_dma_watchdog_enable_req(ctrl);
+
+   netxen_crb_writelit_adapter(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
+
+   return 0;
+}
+
+
 int netxen_is_flash_supported(struct netxen_adapter *adapter);
 int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]);
 extern void netxen_change_ringparam(struct netxen_adapter *adapter);
Index: netdev-2.6/drivers/net/netxen/netxen_nic_hdr.h
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic_hdr.h
+++ netdev-2.6/drivers/net/netxen/netxen_nic_hdr.h
@@ -687,4 +687,6 @@ enum {
 
 #define PCIE_MAX_MASTER_SPLIT  (0x14048)
 
+#define NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL   (0x14)
+
 #endif /* __NETXEN_NIC_HDR_H_ */
Index: netdev-2.6/drivers/net/netxen/netxen_nic_hw.c
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic_hw.c
+++ netdev-2.6/drivers/net/netxen/netxen_nic_hw.c
@@ -377,7 +377,7 @@ int netxen_nic_hw_resources(struct netxe

Re: [PATCH 3/3] NetXen: Graceful teardown of interface and hardware upon module unload

2007-06-30 Thread Dhananjay Phadke

This stage is safe to bail out on signal. It's initializing about a
hundred registers
and trying to guaranty by retrying, so can get stretched too much on faulty h/w.

-Dhananjay

On 7/1/07, Jeff Garzik [EMAIL PROTECTED] wrote:

While strictly this is true, I strongly urge the use of
non-interruptible sleeps when used in hardware-related delays.  Very
rarely does one really want to care about signals for such cases.

Jeff

-
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


RESEND [PATCH 0/3] NetXen: Bug fixes for multiport and blade adapters

2007-06-30 Thread dhananjay . phadke
Resending with changes suggested.

-- 
Dhananjay Phadke
NetXen Inc.

 drivers/net/netxen/netxen_nic.h  |  177 +++---
 drivers/net/netxen/netxen_nic_hdr.h  |2 +
 drivers/net/netxen/netxen_nic_hw.c   |   39 +--
 drivers/net/netxen/netxen_nic_init.c |   64 +++
 drivers/net/netxen/netxen_nic_main.c |  177 +++---
 drivers/net/netxen/netxen_nic_phan_reg.h |   14 +++
 6 files changed, 357 insertions(+), 116 deletions(-)
-
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


RESEND [PATCH 1/3] NetXen: Fix issue of MSI not working correctly

2007-06-30 Thread dhananjay . phadke
NetXen driver uses PCI function 0 to provide the functionality of MSI.
The patch makes driver check the bus master bit for function 0 and
enable it after the card initialization.

Signed-off-by: Dhananjay Phadke[EMAIL PROTECTED]
Signed-off-by: Milan Bag [EMAIL PROTECTED]
Signed-off-by: Wen Xiong [EMAIL PROTECTED]

Index: netdev-2.6/drivers/net/netxen/netxen_nic_main.c
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic_main.c
+++ netdev-2.6/drivers/net/netxen/netxen_nic_main.c
@@ -336,11 +336,9 @@ netxen_nic_probe(struct pci_dev *pdev, c
if (pci_using_dac)
netdev-features |= NETIF_F_HIGHDMA;
 
-   if (pci_enable_msi(pdev)) {
+   if (pci_enable_msi(pdev))
adapter-flags = ~NETXEN_NIC_MSI_ENABLED;
-   printk(KERN_WARNING %s: unable to allocate MSI interrupt
-   error\n, netxen_nic_driver_name);
-   } else
+   else
adapter-flags |= NETXEN_NIC_MSI_ENABLED;
 
netdev-irq = pdev-irq;
@@ -355,13 +353,6 @@ netxen_nic_probe(struct pci_dev *pdev, c
/* initialize the adapter */
netxen_initialize_adapter_hw(adapter);
 
-#ifdef CONFIG_PPC
-   if ((adapter-ahw.boardcfg.board_type ==
-   NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) 
-   (pci_func_id == 2))
-   goto err_out_free_adapter;
-#endif /* CONFIG_PPC */
-
/*
 *  Adapter in our case is quad port so initialize it before
 *  initializing the ports
@@ -509,16 +500,22 @@ netxen_nic_probe(struct pci_dev *pdev, c
NETXEN_CAM_RAM(0x1fc)));
if (val == 0x) {
/* This is the first boot after power up */
+   netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(0x4), val);
+   if (!(val  0x4)) {
+   val |= 0x4;
+   netxen_nic_write_w0(adapter, NETXEN_PCIE_REG(0x4), val);
+   netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(0x4), val);
+   }
val = readl(NETXEN_CRB_NORMALIZE(adapter,
NETXEN_ROMUSB_GLB_SW_RESET));
printk(KERN_INFONetXen: read 0x%08x for reset reg.\n,val);
if (val != 0x8f) {
/* clear the register for future unloads/loads */
-   writel(0, NETXEN_CRB_NORMALIZE(adapter,
-   NETXEN_CAM_RAM(0x1fc)));
-   printk(KERN_ERR ERROR in NetXen HW init sequence.\n);
-   err = -ENODEV;
-   goto err_out_free_dev;
+   writel(0, NETXEN_CRB_NORMALIZE(adapter,
+   NETXEN_CAM_RAM(0x1fc)));
+   printk(KERN_ERR ERROR in NetXen HW init 
sequence.\n);
+   err = -ENODEV;
+   goto err_out_free_dev;
}
 
/* clear the register for future unloads/loads */

-- 
-
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


RESEND [PATCH 2/3] NetXen: Support per PCI-function interrupt mask registers

2007-06-30 Thread dhananjay . phadke
This patch updates the various access routines to access different
control and status settings present in different register locations.
This will fix problems related to working of different ports in
multi Port card.

Signed-off by: Dhananjay Phadke [EMAIL PROTECTED]
Signed-off by: Milan Bag [EMAIL PROTECTED]

Index: netdev-2.6/drivers/net/netxen/netxen_nic.h
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic.h
+++ netdev-2.6/drivers/net/netxen/netxen_nic.h
@@ -937,6 +937,7 @@ struct netxen_adapter {
struct netxen_ring_ctx *ctx_desc;
struct pci_dev *ctx_desc_pdev;
dma_addr_t ctx_desc_phys_addr;
+   int intr_scheme;
int (*enable_phy_interrupts) (struct netxen_adapter *);
int (*disable_phy_interrupts) (struct netxen_adapter *);
void (*handle_phy_intr) (struct netxen_adapter *);
@@ -1080,37 +1081,103 @@ struct net_device_stats *netxen_nic_get_
 
 static inline void netxen_nic_disable_int(struct netxen_adapter *adapter)
 {
-   /*
-* ISR_INT_MASK: Can be read from window 0 or 1.
-*/
-   writel(0x7ff, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
+   uint32_tmask = 0x7ff;
+   int count = 0;
 
+   DPRINTK(1, INFO, Entered ISR Disable \n);
+
+   switch (adapter-portnum) {
+   case 0:
+   writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_0));
+   break;
+   case 1:
+   writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_1));
+   break;
+   case 2:
+   writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_2));
+   break;
+   case 3:
+   writel(0x0, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_3));
+   break;
+   }
+
+   if (adapter-intr_scheme != -1 
+   adapter-intr_scheme != INTR_SCHEME_PERPORT) {
+   writel(mask,
+   (void *)(PCI_OFFSET_SECOND_RANGE(adapter, 
ISR_INT_MASK)));
+   }
+
+   /* Window = 0 or 1 */
+   if (!(adapter-flags  NETXEN_NIC_MSI_ENABLED)) {
+   do {
+   writel(0x, (void *)
+   (PCI_OFFSET_SECOND_RANGE(adapter, 
ISR_INT_TARGET_STATUS)));
+   mask = readl((void *)
+   (pci_base_offset(adapter, 
ISR_INT_VECTOR)));
+   udelay(10);
+   } while (((mask  0x80) != 0)  (++count  32));
+
+   if ((mask  0x80) != 0) {
+   printk(KERN_NOTICE Could not disable interrupt 
completely\n);
+   }
+   }
+
+   DPRINTK(1, INFO, Done with Disable Int\n);
+
+   return;
 }
 
 static inline void netxen_nic_enable_int(struct netxen_adapter *adapter)
 {
u32 mask;
 
-   switch (adapter-ahw.board_type) {
-   case NETXEN_NIC_GBE:
-   mask = 0x77b;
+   DPRINTK(1, INFO, Entered ISR Enable \n);
+
+   if (adapter-intr_scheme != -1 
+   adapter-intr_scheme != INTR_SCHEME_PERPORT) {
+   switch (adapter-ahw.board_type) {
+   case NETXEN_NIC_GBE:
+   mask  =  0x77b;
+   break;
+   case NETXEN_NIC_XGBE:
+   mask  =  0x77f;
+   break;
+   default:
+   mask  =  0x7ff;
+   break;
+   }
+
+   writel(mask,
+   (void *)(PCI_OFFSET_SECOND_RANGE(adapter, 
ISR_INT_MASK)));
+   }
+   switch (adapter-portnum) {
+   case 0:
+   writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_0));
+   break;
+   case 1:
+   writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_1));
break;
-   case NETXEN_NIC_XGBE:
-   mask = 0x77f;
+   case 2:
+   writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_2));
break;
-   default:
-   mask = 0x7ff;
+   case 3:
+   writel(0x1, NETXEN_CRB_NORMALIZE(adapter, CRB_SW_INT_MASK_3));
break;
}
 
-   writel(mask, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
-
if (!(adapter-flags  NETXEN_NIC_MSI_ENABLED)) {
mask = 0xbff;
-   writel(0X0, NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR));
-   writel(mask, PCI_OFFSET_SECOND_RANGE(adapter,
-ISR_INT_TARGET_MASK));
+   if (adapter-intr_scheme != -1 
+   adapter-intr_scheme != INTR_SCHEME_PERPORT) {
+   writel(0X0, NETXEN_CRB_NORMALIZE(adapter, 
CRB_INT_VECTOR));
+   }
+   writel(mask,
+   (void *)(PCI_OFFSET_SECOND_RANGE(adapter, 
ISR_INT_TARGET_MASK

RESEND [PATCH 3/3] NetXen: Graceful teardown of interface and hardware upon module unload

2007-06-30 Thread dhananjay . phadke
These changes allow driver close routine to be called during module unload,
to clean-up buffers and other software resources, flush queues etc. Also,
hardware is reset to pristine state. 

Signed-off-by: Dhananjay Phadke [EMAIL PROTECTED]
Signed-off-by: Milan Bag [EMAIL PROTECTED]
Signed-off-by: Wen Xiong [EMAIL PROTECTED]

Index: netdev-2.6/drivers/net/netxen/netxen_nic.h
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic.h
+++ netdev-2.6/drivers/net/netxen/netxen_nic.h
@@ -952,6 +952,24 @@ struct netxen_adapter {
int (*stop_port) (struct netxen_adapter *);
 }; /* netxen_adapter structure */
 
+/*
+ * NetXen dma watchdog control structure
+ *
+ * Bit 0   : enabled = R/O: 1 watchdog active, 0 inactive
+ * Bit 1   : disable_request = 1 req disable dma watchdog
+ * Bit 2   : enable_request =  1 req enable dma watchdog
+ * Bit 3-31: unused
+ */
+
+#define netxen_set_dma_watchdog_disable_req(config_word) \
+   _netxen_set_bits(config_word, 1, 1, 1)
+#define netxen_set_dma_watchdog_enable_req(config_word) \
+   _netxen_set_bits(config_word, 2, 1, 1)
+#define netxen_get_dma_watchdog_enabled(config_word) \
+   ((config_word)  0x1)
+#define netxen_get_dma_watchdog_disabled(config_word) \
+   (((config_word)  1)  0x1)
+
 /* Max number of xmit producer threads that can run simultaneously */
 #defineMAX_XMIT_PRODUCERS  16
 
@@ -1031,8 +1049,8 @@ int netxen_nic_erase_pxe(struct netxen_a
 /* Functions from netxen_nic_init.c */
 void netxen_free_adapter_offload(struct netxen_adapter *adapter);
 int netxen_initialize_adapter_offload(struct netxen_adapter *adapter);
-void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
-void netxen_load_firmware(struct netxen_adapter *adapter);
+int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
+int 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, 
@@ -1231,6 +1249,62 @@ static inline void get_brd_name_by_type(
name = Unknown;
 }
 
+static inline int
+dma_watchdog_shutdown_request(struct netxen_adapter *adapter)
+{
+   u32 ctrl;
+
+   /* check if already inactive */
+   if (netxen_nic_hw_read_wx(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl, 4))
+   printk(KERN_ERR failed to read dma watchdog status\n);
+
+   if (netxen_get_dma_watchdog_enabled(ctrl) == 0)
+   return 1;
+
+   /* Send the disable request */
+   netxen_set_dma_watchdog_disable_req(ctrl);
+   netxen_crb_writelit_adapter(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
+
+   return 0;
+}
+
+static inline int
+dma_watchdog_shutdown_poll_result(struct netxen_adapter *adapter)
+{
+   u32 ctrl;
+
+   if (netxen_nic_hw_read_wx(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl, 4))
+   printk(KERN_ERR failed to read dma watchdog status\n);
+
+   return ((netxen_get_dma_watchdog_enabled(ctrl) == 0) 
+   (netxen_get_dma_watchdog_disabled(ctrl) == 0));
+}
+
+static inline int
+dma_watchdog_wakeup(struct netxen_adapter *adapter)
+{
+   u32 ctrl;
+
+   if (netxen_nic_hw_read_wx(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl, 4))
+   printk(KERN_ERR failed to read dma watchdog status\n);
+
+   if (netxen_get_dma_watchdog_enabled(ctrl))
+   return 1;
+
+   /* send the wakeup request */
+   netxen_set_dma_watchdog_enable_req(ctrl);
+
+   netxen_crb_writelit_adapter(adapter,
+   NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
+
+   return 0;
+}
+
+
 int netxen_is_flash_supported(struct netxen_adapter *adapter);
 int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]);
 extern void netxen_change_ringparam(struct netxen_adapter *adapter);
Index: netdev-2.6/drivers/net/netxen/netxen_nic_hdr.h
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic_hdr.h
+++ netdev-2.6/drivers/net/netxen/netxen_nic_hdr.h
@@ -687,4 +687,6 @@ enum {
 
 #define PCIE_MAX_MASTER_SPLIT  (0x14048)
 
+#define NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL   (0x14)
+
 #endif /* __NETXEN_NIC_HDR_H_ */
Index: netdev-2.6/drivers/net/netxen/netxen_nic_hw.c
===
--- netdev-2.6.orig/drivers/net/netxen/netxen_nic_hw.c
+++ netdev-2.6/drivers/net/netxen/netxen_nic_hw.c
@@ -377,7 +377,7 @@ int netxen_nic_hw_resources(struct netxe

Re: [PATCH 3/4] NetXen: Add correct routines to setup multicast address

2007-06-12 Thread Dhananjay Phadke
Mithlesh,

You don't initialize max_mc_count anywhere. The multicast address pool
can hold 16 addresses for ports {0,1} and 4 for ports {2,3}. You should
have following line in the probe routine.

 adapter-max_mc_count = (adapter-portnum  1) ? 4 : 16;

--
Dhananjay Phadke
NetXen Inc.


Mithlesh Thukral wrote:
 NetXen: Add multi cast filter code
 This patch adds multi cast filter code to NetXen NIC driver.
 It also adds capabilities to setup the multicast address in hardware
 from the host side.
 
 Signed-off by: Mithlesh Thukral [EMAIL PROTECTED]
 ---
 
  drivers/net/netxen/netxen_nic.h |   24 +
  drivers/net/netxen/netxen_nic_hdr.h |3 
  drivers/net/netxen/netxen_nic_hw.c  |  119 +-
  3 files changed, 143 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
 index a0b39ee..2fddfd1 100644
 --- a/drivers/net/netxen/netxen_nic.h
 +++ b/drivers/net/netxen/netxen_nic.h
 @@ -261,6 +261,27 @@ #define netxen_set_msg_ctxid(config_word
  #define netxen_set_msg_opcode(config_word, val)  \
   ((config_word) = ~(0xf28), (config_word) |= (val  0xf)  28)
  
 +#define netxen_set_addr_ctl_id_pool0(config_word, val)   \
 + ((config_word) = ~3, (config_word) |= val  0x3)
 +#define netxen_set_addr_ctl_enable_xtnd_0(config_word)   \
 + ((config_word) |= 1  2)
 +#define netxen_set_addr_ctl_id_pool1(config_word, val)   \
 + ((config_word) = ~(0x34), (config_word) |= (val  0x3)  4)
 +#define netxen_set_addr_ctl_enable_xtnd_1(config_word)   \
 + ((config_word) |= 1  6)
 +#define netxen_set_addr_ctl_id_pool2(config_word, val)   \
 + ((config_word) = ~(0x38), (config_word) |= (val  0x3)  8)
 +#define netxen_set_addr_ctl_enable_xtnd_2(config_word)   \
 + ((config_word) |= 1  10)
 +#define netxen_set_addr_ctl_id_pool3(config_word, val)   \
 + ((config_word) = ~(0x312), (config_word) |= (val  0x3)  12)
 +#define netxen_set_addr_ctl_enable_xtnd_3(config_word)   \
 + ((config_word) |= 1  14)
 +#define netxen_set_addr_ctl_mode(config_word, val)   \
 + ((config_word) = ~(0x326), (config_word) |= (val  0x3)  26)
 +#define netxen_set_addr_ctl_enable_poll(config_word, val)\
 + ((config_word) = ~(0xf30), (config_word) |= (val  0xf)  30)
 +
  struct netxen_rcv_context {
   __le64 rcv_ring_addr;
   __le32 rcv_ring_size;
 @@ -883,6 +904,9 @@ struct netxen_adapter {
   unsigned char mac_addr[ETH_ALEN];
   int mtu;
   int portnum;
 + u8 promisc;
 + u8 mc_enabled;
 + u8 max_mc_count;
  
   spinlock_t tx_lock;
   spinlock_t lock;
 diff --git a/drivers/net/netxen/netxen_nic_hdr.h 
 b/drivers/net/netxen/netxen_nic_hdr.h
 index 608e37b..2bfecbc 100644
 --- a/drivers/net/netxen/netxen_nic_hdr.h
 +++ b/drivers/net/netxen/netxen_nic_hdr.h
 @@ -545,6 +545,9 @@ #define NETXEN_MULTICAST_ADDR_HI_1(NETX
  #define NETXEN_MULTICAST_ADDR_HI_2   (NETXEN_CRB_NIU + 0x1018)
  #define NETXEN_MULTICAST_ADDR_HI_3   (NETXEN_CRB_NIU + 0x101c)
  
 +#define NETXEN_UNICAST_ADDR_BASE (NETXEN_CRB_NIU + 0x1080)
 +#define NETXEN_MULTICAST_ADDR_BASE   (NETXEN_CRB_NIU + 0x1100)
 +
  #define  NETXEN_NIU_GB_MAC_CONFIG_0(I)   \
   (NETXEN_CRB_NIU + 0x3 + (I)*0x1)
  #define  NETXEN_NIU_GB_MAC_CONFIG_1(I)   \
 diff --git a/drivers/net/netxen/netxen_nic_hw.c 
 b/drivers/net/netxen/netxen_nic_hw.c
 index baff17a..c5d4ff9 100644
 --- a/drivers/net/netxen/netxen_nic_hw.c
 +++ b/drivers/net/netxen/netxen_nic_hw.c
 @@ -303,6 +303,97 @@ int netxen_nic_set_mac(struct net_device
   return 0;
  }
  
 +#define NETXEN_UNICAST_ADDR(port, index) \
 + (NETXEN_UNICAST_ADDR_BASE+(port*32)+(index*8))
 +
 +int netxen_nic_enable_mcast_filter(struct netxen_adapter *adapter)
 +{
 + u32 val = 0;
 + u16 port = physical_port[adapter-portnum];
 +
 + if (adapter-mc_enabled)
 + return 0;
 + 
 + netxen_set_addr_ctl_enable_poll(val, 0xf);
 +
 + if (adapter-ahw.board_type == NETXEN_NIC_XGBE)
 + netxen_set_addr_ctl_mode(val, 0x3);
 + else
 + netxen_set_addr_ctl_mode(val, 0x0);
 +
 + netxen_set_addr_ctl_id_pool0(val, 0x0);
 + netxen_set_addr_ctl_id_pool1(val, 0x1);
 + netxen_set_addr_ctl_id_pool2(val, 0x2);
 + netxen_set_addr_ctl_id_pool3(val, 0x3);
 +
 + netxen_set_addr_ctl_enable_xtnd_0(val);
 + netxen_set_addr_ctl_enable_xtnd_1(val);
 + netxen_set_addr_ctl_enable_xtnd_2(val);
 + netxen_set_addr_ctl_enable_xtnd_3(val);
 + 
 + netxen_crb_writelit_adapter(adapter, NETXEN_MAC_ADDR_CNTL_REG, val);
 + 
 + val = 0xff;
 +
 + netxen_crb_writelit_adapter(adapter, NETXEN_UNICAST_ADDR(port,0), val);
 + netxen_crb_writelit_adapter(adapter, NETXEN_UNICAST_ADDR(port,0)+4, 
 + val);
 + 
 + memcpy(val, adapter-mac_addr, 3);
 + netxen_crb_writelit_adapter(adapter, NETXEN_UNICAST_ADDR(port