[PATCH 2.6.24 1/1]S2io: Fixed memory leak by freeing MSI-X local entry memories when vector allocation fails

2007-10-28 Thread Sivakumar Subramani
- Fixed memory leak by freeing MSI-X local entry memories when vector allocation
fails in s2io_add_isr.
- Added two utility functions do_rem_msix_isr and do_rem_inta_isr to eliminate
code duplication.

Signed-off-by: Veena Parat [EMAIL PROTECTED]
Signed-off-by: Ramkrishna Vepa [EMAIL PROTECTED]
Signed-off-by: Santosh Rastapur [EMAIL PROTECTED]
---
diff -Nurp 2-0-26-6/drivers/net/s2io.c 2-0-26-7/drivers/net/s2io.c
--- 2-0-26-6/drivers/net/s2io.c 2007-10-24 09:20:39.0 -0700
+++ 2-0-26-7/drivers/net/s2io.c 2007-10-24 09:46:16.0 -0700
@@ -84,7 +84,7 @@
 #include s2io.h
 #include s2io-regs.h
 
-#define DRV_VERSION 2.0.26.6
+#define DRV_VERSION 2.0.26.7
 
 /* S2io Driver name  version. */
 static char s2io_driver_name[] = Neterion;
@@ -3775,6 +3775,46 @@ static int __devinit s2io_test_msi(struc
 
return err;
 }
+
+static void do_rem_msix_isr(struct s2io_nic * sp)
+{
+   struct swStat *stats = sp-mac_control.stats_info-sw_stat;
+   int i;
+   u16 msi_control;
+
+   for (i=1; (sp-s2io_entries[i].in_use ==
+   MSIX_REGISTERED_SUCCESS); i++) {
+   int vector = sp-entries[i].vector;
+   void *arg = sp-s2io_entries[i].arg;
+
+   synchronize_irq(vector);
+   free_irq(vector, arg);
+   }
+
+   kfree(sp-entries);
+   stats-mem_freed +=
+   (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
+   kfree(sp-s2io_entries);
+   stats-mem_freed +=
+   (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
+   sp-entries = NULL;
+   sp-s2io_entries = NULL;
+
+   pci_read_config_word(sp-pdev, 0x42, msi_control);
+   msi_control = 0xFFFE; /* Disable MSI */
+   pci_write_config_word(sp-pdev, 0x42, msi_control);
+
+   pci_disable_msix(sp-pdev);
+}
+
+static void do_rem_inta_isr(struct s2io_nic * sp)
+{
+   struct net_device *dev = sp-dev;
+
+   synchronize_irq(sp-pdev-irq);
+   free_irq(sp-pdev-irq, dev);
+}
+
 /* * *
  * Functions defined below concern the OS part of the driver *
  * * */
@@ -3809,28 +3849,11 @@ static int s2io_open(struct net_device *
int ret = s2io_enable_msi_x(sp);
 
if (!ret) {
-   u16 msi_control;
 
ret = s2io_test_msi(sp);
 
/* rollback MSI-X, will re-enable during add_isr() */
-   kfree(sp-entries);
-   sp-mac_control.stats_info-sw_stat.mem_freed +=
-   (MAX_REQUESTED_MSI_X *
-   sizeof(struct msix_entry));
-   kfree(sp-s2io_entries);
-   sp-mac_control.stats_info-sw_stat.mem_freed +=
-   (MAX_REQUESTED_MSI_X *
-   sizeof(struct s2io_msix_entry));
-   sp-entries = NULL;
-   sp-s2io_entries = NULL;
-
-   pci_read_config_word(sp-pdev, 0x42, msi_control);
-   msi_control = 0xFFFE; /* Disable MSI */
-   pci_write_config_word(sp-pdev, 0x42, msi_control);
-
-   pci_disable_msix(sp-pdev);
-
+   do_rem_msix_isr(sp);
}
if (ret) {
 
@@ -6864,15 +6887,22 @@ static int s2io_add_isr(struct s2io_nic 
}
}
if (err) {
+   do_rem_msix_isr(sp);
+
DBG_PRINT(ERR_DBG,%s:MSI-X-%d registration 
  failed\n, dev-name, i);
-   DBG_PRINT(ERR_DBG, Returned: %d\n, err);
-   return -1;
+
+   DBG_PRINT(ERR_DBG, %s: Defaulting to INTA\n,
+   dev-name);
+   sp-config.intr_type = INTA;
+   break;
}
sp-s2io_entries[i].in_use = MSIX_REGISTERED_SUCCESS;
}
-   printk(MSI-X-TX %d entries enabled\n,msix_tx_cnt);
-   printk(MSI-X-RX %d entries enabled\n,msix_rx_cnt);
+   if(!err) {
+   printk(MSI-X-TX %d entries enabled\n,msix_tx_cnt);
+   printk(MSI-X-RX %d entries enabled\n,msix_rx_cnt);
+   }
}
if (sp-config.intr_type == INTA) {
err = request_irq((int) sp-pdev-irq, s2io_isr, IRQF_SHARED,
@@ -6887,40 +6917,10 @@ static int s2io_add_isr(struct s2io_nic 
 }
 static void s2io_rem_isr(struct s2io_nic * sp)
 {
-   struct net_device *dev = sp-dev;
-   struct swStat *stats = sp-mac_control.stats_info-sw_stat;
-
-   if (sp-config.intr_type == MSI_X) {
-   int 

[PATCH 2.6.24 1/2]S2io: Change kmalloc+memset to k[zc]alloc

2007-09-14 Thread Sivakumar Subramani
- Changed kmalloc+memset to k[zc]alloc as per Mariusz's patch
  [EMAIL PROTECTED]

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
Signed-off-by: Ramkrishna Vepa [EMAIL PROTECTED]
---
diff -urpN org/drivers/net/s2io.c patch1/drivers/net/s2io.c
--- org/drivers/net/s2io.c  2007-08-09 17:28:19.0 +0530
+++ patch1/drivers/net/s2io.c   2007-08-10 11:53:46.0 +0530
@@ -556,7 +556,7 @@ static int init_shared_mem(struct s2io_n
for (i = 0; i  config-tx_fifo_num; i++) {
int fifo_len = config-tx_cfg[i].fifo_len;
int list_holder_size = fifo_len * sizeof(struct list_info_hold);
-   mac_control-fifos[i].list_info = kmalloc(list_holder_size,
+   mac_control-fifos[i].list_info = kzalloc(list_holder_size,
  GFP_KERNEL);
if (!mac_control-fifos[i].list_info) {
DBG_PRINT(INFO_DBG,
@@ -564,7 +564,6 @@ static int init_shared_mem(struct s2io_n
return -ENOMEM;
}
mem_allocated += list_holder_size;
-   memset(mac_control-fifos[i].list_info, 0, list_holder_size);
}
for (i = 0; i  config-tx_fifo_num; i++) {
int page_num = TXD_MEM_PAGE_CNT(config-tx_cfg[i].fifo_len,
@@ -3883,9 +3882,9 @@ static int s2io_enable_msi_x(struct s2io
u16 msi_control; /* Temp variable */
int ret, i, j, msix_indx = 1;
 
-   nic-entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry),
+   nic-entries = kcalloc(MAX_REQUESTED_MSI_X, sizeof(struct msix_entry),
   GFP_KERNEL);
-   if (nic-entries == NULL) {
+   if (!nic-entries) {
DBG_PRINT(INFO_DBG, %s: Memory allocation failed\n, \
__FUNCTION__);
nic-mac_control.stats_info-sw_stat.mem_alloc_fail_cnt++;
@@ -3893,12 +3892,11 @@ static int s2io_enable_msi_x(struct s2io
}
nic-mac_control.stats_info-sw_stat.mem_allocated 
+= (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
-   memset(nic-entries, 0,MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
 
nic-s2io_entries =
-   kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry),
+   kcalloc(MAX_REQUESTED_MSI_X, sizeof(struct s2io_msix_entry),
   GFP_KERNEL);
-   if (nic-s2io_entries == NULL) {
+   if (!nic-s2io_entries) {
DBG_PRINT(INFO_DBG, %s: Memory allocation failed\n, 
__FUNCTION__);
nic-mac_control.stats_info-sw_stat.mem_alloc_fail_cnt++;
@@ -3909,8 +3907,6 @@ static int s2io_enable_msi_x(struct s2io
}
 nic-mac_control.stats_info-sw_stat.mem_allocated 
+= (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
-   memset(nic-s2io_entries, 0,
-  MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
 
for (i=0; i MAX_REQUESTED_MSI_X; i++) {
nic-entries[i].entry = i;

-
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.24 2/2]S2io: Removed unused feature - bimodal interrupts

2007-09-14 Thread Sivakumar Subramani
- Removed bimodal interrupt support - unused feature

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
Signed-off-by: Ramkrishna Vepa [EMAIL PROTECTED]
---
diff -pNur prior/drivers/net/s2io.c patch_dir/drivers/net/s2io.c
--- prior/drivers/net/s2io.c2007-09-06 11:31:04.0 -0700
+++ patch_dir/drivers/net/s2io.c2007-09-06 11:37:10.0 -0700
@@ -84,7 +84,7 @@
 #include s2io.h
 #include s2io-regs.h
 
-#define DRV_VERSION 2.0.26.2
+#define DRV_VERSION 2.0.26.4
 
 /* S2io Driver name  version. */
 static char s2io_driver_name[] = Neterion;
@@ -452,7 +452,6 @@ S2IO_PARM_INT(mc_pause_threshold_q4q7, 1
 S2IO_PARM_INT(shared_splits, 0);
 S2IO_PARM_INT(tmac_util_period, 5);
 S2IO_PARM_INT(rmac_util_period, 5);
-S2IO_PARM_INT(bimodal, 0);
 S2IO_PARM_INT(l3l4hdr_size, 128);
 /* Frequency of Rx desc syncs expressed as power of 2 */
 S2IO_PARM_INT(rxsync_frequency, 3);
@@ -1565,90 +1564,57 @@ static int init_nic(struct s2io_nic *nic
time++;
}
 
-   if (nic-config.bimodal) {
-   int k = 0;
-   for (k = 0; k  config-rx_ring_num; k++) {
-   val64 = TTI_CMD_MEM_WE | TTI_CMD_MEM_STROBE_NEW_CMD;
-   val64 |= TTI_CMD_MEM_OFFSET(0x38+k);
-   writeq(val64, bar0-tti_command_mem);
-
+   /* RTI Initialization */
+   if (nic-device_type == XFRAME_II_DEVICE) {
/*
-* Once the operation completes, the Strobe bit of the command
-* register will be reset. We poll for this particular condition
-* We wait for a maximum of 500ms for the operation to complete,
-* if it's not complete by then we return error.
-   */
-   time = 0;
-   while (TRUE) {
-   val64 = readq(bar0-tti_command_mem);
-   if (!(val64  TTI_CMD_MEM_STROBE_NEW_CMD)) {
-   break;
-   }
-   if (time  10) {
-   DBG_PRINT(ERR_DBG,
-   %s: TTI init Failed\n,
-   dev-name);
-   return -1;
-   }
-   time++;
-   msleep(50);
-   }
-   }
-   } else {
+* Programmed to generate Apprx 500 Intrs per
+* second
+*/
+   int count = (nic-config.bus_speed * 125)/4;
+   val64 = RTI_DATA1_MEM_RX_TIMER_VAL(count);
+   } else
+   val64 = RTI_DATA1_MEM_RX_TIMER_VAL(0xFFF);
+   val64 |= RTI_DATA1_MEM_RX_URNG_A(0xA) |
+   RTI_DATA1_MEM_RX_URNG_B(0x10) |
+   RTI_DATA1_MEM_RX_URNG_C(0x30) | RTI_DATA1_MEM_RX_TIMER_AC_EN;
+
+   writeq(val64, bar0-rti_data1_mem);
+
+   val64 = RTI_DATA2_MEM_RX_UFC_A(0x1) |
+   RTI_DATA2_MEM_RX_UFC_B(0x2) ;
+   if (nic-config.intr_type == MSI_X)
+   val64 |= (RTI_DATA2_MEM_RX_UFC_C(0x20) | \
+   RTI_DATA2_MEM_RX_UFC_D(0x40));
+   else
+   val64 |= (RTI_DATA2_MEM_RX_UFC_C(0x40) | \
+   RTI_DATA2_MEM_RX_UFC_D(0x80));
+   writeq(val64, bar0-rti_data2_mem);
 
-   /* RTI Initialization */
-   if (nic-device_type == XFRAME_II_DEVICE) {
-   /*
-* Programmed to generate Apprx 500 Intrs per
-* second
-*/
-   int count = (nic-config.bus_speed * 125)/4;
-   val64 = RTI_DATA1_MEM_RX_TIMER_VAL(count);
-   } else {
-   val64 = RTI_DATA1_MEM_RX_TIMER_VAL(0xFFF);
-   }
-   val64 |= RTI_DATA1_MEM_RX_URNG_A(0xA) |
-   RTI_DATA1_MEM_RX_URNG_B(0x10) |
-   RTI_DATA1_MEM_RX_URNG_C(0x30) | 
RTI_DATA1_MEM_RX_TIMER_AC_EN;
-
-   writeq(val64, bar0-rti_data1_mem);
-
-   val64 = RTI_DATA2_MEM_RX_UFC_A(0x1) |
-   RTI_DATA2_MEM_RX_UFC_B(0x2) ;
-   if (nic-config.intr_type == MSI_X)
-   val64 |= (RTI_DATA2_MEM_RX_UFC_C(0x20) | \
-   RTI_DATA2_MEM_RX_UFC_D(0x40));
-   else
-   val64 |= (RTI_DATA2_MEM_RX_UFC_C(0x40) | \
-   RTI_DATA2_MEM_RX_UFC_D(0x80));
-   writeq(val64, bar0-rti_data2_mem);
+   for (i = 0; i  config-rx_ring_num; i++) {
+   val64 = RTI_CMD_MEM_WE | RTI_CMD_MEM_STROBE_NEW_CMD
+   | RTI_CMD_MEM_OFFSET(i);
+   writeq(val64, bar0-rti_command_mem);
 
-   for (i = 0; i  config-rx_ring_num; i++) {
-   val64

[PATCH 2.6.24 1/3]S2io: Added support set_mac_address driver entry point

2007-09-14 Thread Sivakumar Subramani
- Added set_mac_address driver entry point
- Copying permanent mac address to dev-perm_addr
- Incorporated following review comments from Jeff
 - Converted the macro to a function and removed call to memset
 - regarding function naming convention, for all callbacks and entry points
   will have 's2io_' prefix and helper functions will have 'do_s2io_' 
prefix.

Signed-off-by: Sreenivasa Honnur [EMAIL PROTECTED]
---
diff -urpN orig/drivers/net/s2io.c patch1/drivers/net/s2io.c
--- orig/drivers/net/s2io.c 2007-09-06 14:30:16.0 +0530
+++ patch1/drivers/net/s2io.c   2007-09-06 16:21:33.0 +0530
@@ -355,6 +355,16 @@ static char ethtool_driver_stats_keys[][
timer.data = (unsigned long) arg;   \
mod_timer(timer, (jiffies + exp))  \
 
+/* copy mac addr to def_mac_addr array */
+static void do_s2io_copy_mac_addr(struct s2io_nic* sp, int offset, u64 
mac_addr)
+{
+   sp-def_mac_addr[offset].mac_addr[5] = (u8) (mac_addr); 
+   sp-def_mac_addr[offset].mac_addr[4] = (u8) (mac_addr  8);
+   sp-def_mac_addr[offset].mac_addr[3] = (u8) (mac_addr  16);
+   sp-def_mac_addr[offset].mac_addr[2] = (u8) (mac_addr  24);
+   sp-def_mac_addr[offset].mac_addr[1] = (u8) (mac_addr  32);
+   sp-def_mac_addr[offset].mac_addr[0] = (u8) (mac_addr  40);
+}
 /* Add the vlan */
 static void s2io_vlan_rx_register(struct net_device *dev,
struct vlan_group *grp)
@@ -3420,7 +3430,7 @@ static void s2io_reset(struct s2io_nic *
}
 
/* restore the previously assigned mac address */
-   s2io_set_mac_addr(sp-dev, (u8 *)sp-def_mac_addr[0].mac_addr);
+   do_s2io_prog_unicast(sp-dev, (u8 *)sp-def_mac_addr[0].mac_addr);
 
sp-device_enabled_once = FALSE;
 }
@@ -3849,7 +3859,7 @@ static int s2io_open(struct net_device *
goto hw_init_failed;
}
 
-   if (s2io_set_mac_addr(dev, dev-dev_addr) == FAILURE) {
+   if (do_s2io_prog_unicast(dev, dev-dev_addr) == FAILURE) {
DBG_PRINT(ERR_DBG, Set Mac Address Failed\n);
s2io_card_down(sp);
err = -ENODEV;
@@ -4847,8 +4857,48 @@ static void s2io_set_multicast(struct ne
}
 }
 
+/* add unicast MAC address to CAM */
+static int do_s2io_add_unicast(struct s2io_nic *sp, u64 addr, int off)
+{
+   u64 val64;
+   struct XENA_dev_config __iomem *bar0 = sp-bar0;
+
+   writeq(RMAC_ADDR_DATA0_MEM_ADDR(addr),
+   bar0-rmac_addr_data0_mem);
+
+   val64 =
+   RMAC_ADDR_CMD_MEM_WE | RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
+   RMAC_ADDR_CMD_MEM_OFFSET(off);
+   writeq(val64, bar0-rmac_addr_cmd_mem);
+
+   /* Wait till command completes */
+   if (wait_for_cmd_complete(bar0-rmac_addr_cmd_mem,
+   RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING,
+   S2IO_BIT_RESET)) {
+   DBG_PRINT(INFO_DBG, add_mac_addr failed\n);
+   return FAILURE;
+   }
+   return SUCCESS;
+}
+
+/**
+ * s2io_set_mac_addr driver entry point
+ */
+static int s2io_set_mac_addr(struct net_device *dev, void* p)
+{
+   struct sockaddr *addr=p;
+
+   if (!is_valid_ether_addr(addr-sa_data))
+   return -EINVAL;
+
+   memcpy(dev-dev_addr, addr-sa_data,dev-addr_len);
+
+   /* store the MAC address in CAM */
+   return (do_s2io_prog_unicast(dev, dev-dev_addr));
+}
+
 /**
- *  s2io_set_mac_addr - Programs the Xframe mac address
+ *  do_s2io_prog_unicast - Programs the Xframe mac address
  *  @dev : pointer to the device structure.
  *  @addr: a uchar pointer to the new mac address which is to be set.
  *  Description : This procedure will program the Xframe to receive
@@ -4856,56 +4906,31 @@ static void s2io_set_multicast(struct ne
  *  Return value: SUCCESS on success and an appropriate (-)ve integer
  *  as defined in errno.h file on failure.
  */
-
-static int s2io_set_mac_addr(struct net_device *dev, u8 * addr)
+static int do_s2io_prog_unicast(struct net_device *dev, u8 * addr)
 {
struct s2io_nic *sp = dev-priv;
-   struct XENA_dev_config __iomem *bar0 = sp-bar0;
-   register u64 val64, mac_addr = 0;
+   register u64 mac_addr = 0,perm_addr=0;
int i;
-   u64 old_mac_addr = 0;
 
/*
-* Set the new MAC address as the new unicast filter and reflect this
-* change on the device address registered with the OS. It will be
-* at offset 0.
-*/
+   * Set the new MAC address as the new unicast filter and reflect this
+   * change on the device address registered with the OS. It will be
+   * at offset 0.
+   */
for (i = 0; i  ETH_ALEN; i++) {
mac_addr = 8;
mac_addr |= addr[i];
-   old_mac_addr = 8;
-   old_mac_addr |= sp-def_mac_addr[0].mac_addr[i];
+   perm_addr = 8;
+   perm_addr |= sp-def_mac_addr[0].mac_addr[i];
 

[PATCH 2.6.24 2/3]S2io: Support for add/delete/store/restore ethernet addresses

2007-09-14 Thread Sivakumar Subramani
- Support to add/delete/store/restore 64 and 128 Ethernet addresses for Xframe 
I and Xframe II respectively.

Signed-off-by: Sreenivasa Honnur [EMAIL PROTECTED]
---
diff -Nurp 2.0.26.5-1/drivers/net/s2io.c 2.0.26.5-2/drivers/net/s2io.c
--- 2.0.26.5-1/drivers/net/s2io.c   2007-09-06 14:42:24.0 -0700
+++ 2.0.26.5-2/drivers/net/s2io.c   2007-09-06 15:45:10.0 -0700
@@ -356,7 +356,7 @@ static char ethtool_driver_stats_keys[][
mod_timer(timer, (jiffies + exp))  \
 
 /* copy mac addr to def_mac_addr array */
-static void do_s2io_copy_mac_addr(struct s2io_nic* sp, int offset, u64 
mac_addr)
+static void do_s2io_copy_mac_addr(struct s2io_nic *sp, int offset, u64 
mac_addr)
 {
sp-def_mac_addr[offset].mac_addr[5] = (u8) (mac_addr); 
sp-def_mac_addr[offset].mac_addr[4] = (u8) (mac_addr  8);
@@ -3371,6 +3371,9 @@ static void s2io_reset(struct s2io_nic *
/* Set swapper to enable I/O register access */
s2io_set_swapper(sp);
 
+   /* restore mac address entries */
+   do_s2io_restore_unicast_mc(sp);
+
/* Restore the MSIX table entries from local variables */
restore_xmsi_data(sp);
 
@@ -3429,9 +3432,6 @@ static void s2io_reset(struct s2io_nic *
writeq(val64, bar0-pcc_err_reg);
}
 
-   /* restore the previously assigned mac address */
-   do_s2io_prog_unicast(sp-dev, (u8 *)sp-def_mac_addr[0].mac_addr);
-
sp-device_enabled_once = FALSE;
 }
 
@@ -3901,8 +3901,17 @@ hw_init_failed:
 static int s2io_close(struct net_device *dev)
 {
struct s2io_nic *sp = dev-priv;
+   struct config_param *config = sp-config;
+   u64 tmp64;
+   int off;
 
netif_stop_queue(dev);
+   /* delete all populated mac entries */
+   for(off =1; off  config-max_mc_addr; off++) {
+   tmp64 = do_s2io_read_unicast_mc(sp,off);
+   if(tmp64 != S2IO_DISABLE_MAC_ENTRY)
+   do_s2io_delete_unicast_mc(sp, tmp64);
+   }
/* Reset card, kill tasklet and free Tx and Rx buffers. */
s2io_card_down(sp);
 
@@ -4701,8 +4710,9 @@ static void s2io_set_multicast(struct ne
struct XENA_dev_config __iomem *bar0 = sp-bar0;
u64 val64 = 0, multi_mac = 0x010203040506ULL, mask =
0xfeffULL;
-   u64 dis_addr = 0xULL, mac_addr = 0;
+   u64 dis_addr = S2IO_DISABLE_MAC_ENTRY, mac_addr = 0;
void __iomem *add;
+   struct config_param *config = sp-config;
 
if ((dev-flags  IFF_ALLMULTI)  (!sp-m_cast_flg)) {
/*  Enable all Multicast addresses */
@@ -4712,7 +4722,7 @@ static void s2io_set_multicast(struct ne
   bar0-rmac_addr_data1_mem);
val64 = RMAC_ADDR_CMD_MEM_WE |
RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
-   RMAC_ADDR_CMD_MEM_OFFSET(MAC_MC_ALL_MC_ADDR_OFFSET);
+   RMAC_ADDR_CMD_MEM_OFFSET(config-max_mc_addr - 1);
writeq(val64, bar0-rmac_addr_cmd_mem);
/* Wait till command completes */
wait_for_cmd_complete(bar0-rmac_addr_cmd_mem,
@@ -4720,7 +4730,7 @@ static void s2io_set_multicast(struct ne
S2IO_BIT_RESET);
 
sp-m_cast_flg = 1;
-   sp-all_multi_pos = MAC_MC_ALL_MC_ADDR_OFFSET;
+   sp-all_multi_pos = config-max_mc_addr - 1;
} else if ((dev-flags  IFF_ALLMULTI)  (sp-m_cast_flg)) {
/*  Disable all Multicast addresses */
writeq(RMAC_ADDR_DATA0_MEM_ADDR(dis_addr),
@@ -4789,7 +4799,8 @@ static void s2io_set_multicast(struct ne
/*  Update individual M_CAST address list */
if ((!sp-m_cast_flg)  dev-mc_count) {
if (dev-mc_count 
-   (MAX_ADDRS_SUPPORTED - MAC_MC_ADDR_START_OFFSET - 1)) {
+   ((config-max_mc_addr - config-max_mac_addr) 
+   - config-mc_start_offset  - 1)) {
DBG_PRINT(ERR_DBG, %s: No more Rx filters ,
  dev-name);
DBG_PRINT(ERR_DBG, can be added, please enable );
@@ -4809,7 +4820,7 @@ static void s2io_set_multicast(struct ne
val64 = RMAC_ADDR_CMD_MEM_WE |
RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
RMAC_ADDR_CMD_MEM_OFFSET
-   (MAC_MC_ADDR_START_OFFSET + i);
+   (config-mc_start_offset + i);
writeq(val64, bar0-rmac_addr_cmd_mem);
 
/* Wait for command completes */
@@ -4841,7 +4852,7 @@ static void s2io_set_multicast(struct ne
val64 = RMAC_ADDR_CMD_MEM_WE |
RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
RMAC_ADDR_CMD_MEM_OFFSET
-   (i + MAC_MC_ADDR_START_OFFSET);
+  

[PATCH 2.6.24 3/3]S2io: Updating transceiver information in ethtool function

2007-09-14 Thread Sivakumar Subramani
- Update transceiver information in ethtool function

Signed-off-by: Sreenivasa Honnur [EMAIL PROTECTED]
---
diff -urpN patch2/drivers/net/s2io.c patch3/drivers/net/s2io.c
--- patch2/drivers/net/s2io.c   2007-09-06 18:31:27.0 +0530
+++ patch3/drivers/net/s2io.c   2007-09-06 18:36:05.0 +0530
@@ -84,7 +84,7 @@
 #include s2io.h
 #include s2io-regs.h
 
-#define DRV_VERSION 2.0.26.4
+#define DRV_VERSION 2.0.26.5
 
 /* S2io Driver name  version. */
 static char s2io_driver_name[] = Neterion;
@@ -5124,7 +5124,9 @@ static int s2io_ethtool_gset(struct net_
info-supported = (SUPPORTED_1baseT_Full | SUPPORTED_FIBRE);
info-advertising = (SUPPORTED_1baseT_Full | SUPPORTED_FIBRE);
info-port = PORT_FIBRE;
-   /* info-transceiver?? TODO */
+
+   /* info-transceiver */
+   info-transceiver = XCVR_EXTERNAL;
 
if (netif_carrier_ok(sp-dev)) {
info-speed = 1;

-
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.24 2/5]S2io: Handle and monitor all of the device errors and alarms

2007-09-06 Thread Sivakumar Subramani
- Added support to poll entire set of device errors and alarams.
- A note on how device errors and alarms are handled:
- The adapter will automatically recover from uncorrectable ECC errors.
  Packets containing corrupted data will be dropped (not transmitted) or tagged
  as invalid before being passed to the host.
- The adapter cannot recover from any internal state machine errors. A state
  machine error requires a device reset.
- Any internal error that could potentially result in .store trampling.
  (undesirable PCI behaviour)is tagged as a serious error. In such cases
  the adapter will give up its ability to be a bus master. In this situation
  the host will still be able to read internal device registers in order to
  generate an error report. A device reset is necessary to return to normal
  operation.
- In the event of a pcix data parity error, the adapter will automatically
  disable itself. Adapter_En will automatically transition from '1' to '0' and
  the adapter will enter its clean-up routine. Once the device has achieved
  quiescence, an adapter reset should be performed.
- Replaced alarm_intr_handler() with s2io_handle_errors().
- Added statistic counters to monitor the alarms.

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
Signed-off-by: Santosh Rastapur [EMAIL PROTECTED]
Signed-off-by: Ramkrishna Vepa [EMAIL PROTECTED]
---
diff -urpN patch_1/drivers/net/s2io.c patch_2/drivers/net/s2io.c
--- patch_1/drivers/net/s2io.c  2007-09-05 13:34:16.0 +0530
+++ patch_2/drivers/net/s2io.c  2007-09-05 13:34:37.0 +0530
@@ -263,7 +263,14 @@ static char ethtool_driver_stats_keys[][
{serious_err_cnt},
{soft_reset_cnt},
{fifo_full_cnt},
-   {ring_full_cnt},
+   {ring_0_full_cnt},
+   {ring_1_full_cnt},
+   {ring_2_full_cnt},
+   {ring_3_full_cnt},
+   {ring_4_full_cnt},
+   {ring_5_full_cnt},
+   {ring_6_full_cnt},
+   {ring_7_full_cnt},
(alarm_transceiver_temp_high),
(alarm_transceiver_temp_low),
(alarm_laser_bias_current_high),
@@ -303,7 +310,24 @@ static char ethtool_driver_stats_keys[][
(rx_tcode_fcs_err_cnt),
(rx_tcode_buf_size_err_cnt),
(rx_tcode_rxd_corrupt_cnt),
-   (rx_tcode_unkn_err_cnt)
+   (rx_tcode_unkn_err_cnt),
+   {tda_err_cnt},
+   {pfc_err_cnt},
+   {pcc_err_cnt},
+   {tti_err_cnt},
+   {tpa_err_cnt},
+   {sm_err_cnt},
+   {lso_err_cnt},
+   {mac_tmac_err_cnt},
+   {mac_rmac_err_cnt},
+   {xgxs_txgxs_err_cnt},
+   {xgxs_rxgxs_err_cnt},
+   {rc_err_cnt},
+   {prc_pcix_err_cnt},
+   {rpa_err_cnt},
+   {rda_err_cnt},
+   {rti_err_cnt},
+   {mc_err_cnt}
 };
 
 #define S2IO_XENA_STAT_LEN sizeof(ethtool_xena_stats_keys)/ ETH_GSTRING_LEN
@@ -1732,6 +1756,7 @@ static int s2io_link_fault_indication(st
else
return MAC_RMAC_ERR_TIMER;
 }
+
 /**
  *  do_s2io_write_bits -  update alarm bits in alarm register
  *  @value: alarm bits
@@ -3260,135 +3285,6 @@ static void s2io_updt_xpak_counter(struc
 }
 
 /**
- *  alarm_intr_handler - Alarm Interrrupt handler
- *  @nic: device private variable
- *  Description: If the interrupt was neither because of Rx packet or Tx
- *  complete, this function is called. If the interrupt was to indicate
- *  a loss of link, the OSM link status handler is invoked for any other
- *  alarm interrupt the block that raised the interrupt is displayed
- *  and a H/W reset is issued.
- *  Return Value:
- *  NONE
-*/
-
-static void alarm_intr_handler(struct s2io_nic *nic)
-{
-   struct net_device *dev = (struct net_device *) nic-dev;
-   struct XENA_dev_config __iomem *bar0 = nic-bar0;
-   register u64 val64 = 0, err_reg = 0;
-   u64 cnt;
-   int i;
-   if (atomic_read(nic-card_state) == CARD_DOWN)
-   return;
-   if (pci_channel_offline(nic-pdev))
-   return;
-   nic-mac_control.stats_info-sw_stat.ring_full_cnt = 0;
-   /* Handling the XPAK counters update */
-   if(nic-mac_control.stats_info-xpak_stat.xpak_timer_count  72000) {
-   /* waiting for an hour */
-   nic-mac_control.stats_info-xpak_stat.xpak_timer_count++;
-   } else {
-   s2io_updt_xpak_counter(dev);
-   /* reset the count to zero */
-   nic-mac_control.stats_info-xpak_stat.xpak_timer_count = 0;
-   }
-
-   /* Handling link status change error Intr */
-   if (s2io_link_fault_indication(nic) == MAC_RMAC_ERR_TIMER) {
-   err_reg = readq(bar0-mac_rmac_err_reg);
-   writeq(err_reg, bar0-mac_rmac_err_reg);
-   if (err_reg  RMAC_LINK_STATE_CHANGE_INT) {
-   schedule_work(nic-set_link_task);
-   }
-   }
-
-   /* Handling Ecc errors */
-   val64 = readq(bar0-mc_err_reg);
-   writeq(val64, bar0-mc_err_reg);
-   if (val64  (MC_ERR_REG_ECC_ALL_SNG | MC_ERR_REG_ECC_ALL_DBL

[PATCH 2.6.24 3/5]S2io: Cleanup - removed unused variable intr_type

2007-09-06 Thread Sivakumar Subramani
- Removed the unused variable, intr_type, in device private structure.

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
Signed-off-by: Santosh Rastapur [EMAIL PROTECTED]
Signed-off-by: Ramkrishna Vepa [EMAIL PROTECTED]
---
diff -urpN patch_2/drivers/net/s2io.c patch_3/drivers/net/s2io.c
--- patch_2/drivers/net/s2io.c  2007-09-05 13:34:37.0 +0530
+++ patch_3/drivers/net/s2io.c  2007-09-05 13:50:34.0 +0530
@@ -1611,7 +1611,7 @@ static int init_nic(struct s2io_nic *nic
 
val64 = RTI_DATA2_MEM_RX_UFC_A(0x1) |
RTI_DATA2_MEM_RX_UFC_B(0x2) ;
-   if (nic-intr_type == MSI_X)
+   if (nic-config.intr_type == MSI_X)
val64 |= (RTI_DATA2_MEM_RX_UFC_C(0x20) | \
RTI_DATA2_MEM_RX_UFC_D(0x40));
else
@@ -1749,7 +1749,7 @@ static int init_nic(struct s2io_nic *nic
 
 static int s2io_link_fault_indication(struct s2io_nic *nic)
 {
-   if (nic-intr_type != INTA)
+   if (nic-config.intr_type != INTA)
return MAC_RMAC_ERR_TIMER;
if (nic-device_type == XFRAME_II_DEVICE)
return LINK_UP_DOWN_INTERRUPT;
@@ -3557,7 +3557,7 @@ static int s2io_set_swapper(struct s2io_
 SWAPPER_CTRL_RXF_W_FE |
 SWAPPER_CTRL_XMSI_FE |
 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE);
-   if (sp-intr_type == INTA)
+   if (sp-config.intr_type == INTA)
val64 |= SWAPPER_CTRL_XMSI_SE;
writeq(val64, bar0-swapper_ctrl);
 #else
@@ -3580,7 +3580,7 @@ static int s2io_set_swapper(struct s2io_
 SWAPPER_CTRL_RXF_W_FE |
 SWAPPER_CTRL_XMSI_FE |
 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE);
-   if (sp-intr_type == INTA)
+   if (sp-config.intr_type == INTA)
val64 |= SWAPPER_CTRL_XMSI_SE;
writeq(val64, bar0-swapper_ctrl);
 #endif
@@ -3854,7 +3854,7 @@ static int s2io_open(struct net_device *
netif_carrier_off(dev);
sp-last_link_state = 0;
 
-   if (sp-intr_type == MSI_X) {
+   if (sp-config.intr_type == MSI_X) {
int ret = s2io_enable_msi_x(sp);
 
if (!ret) {
@@ -3886,12 +3886,12 @@ static int s2io_open(struct net_device *
DBG_PRINT(ERR_DBG,
  %s: MSI-X requested but failed to enable\n,
  dev-name);
-   sp-intr_type = INTA;
+   sp-config.intr_type = INTA;
}
}
 
/* NAPI doesn't work well with MSI(X) */
-if (sp-intr_type != INTA) {
+if (sp-config.intr_type != INTA) {
if(sp-config.napi)
sp-config.napi = 0;
}
@@ -3915,7 +3915,7 @@ static int s2io_open(struct net_device *
return 0;
 
 hw_init_failed:
-   if (sp-intr_type == MSI_X) {
+   if (sp-config.intr_type == MSI_X) {
if (sp-entries) {
kfree(sp-entries);
sp-mac_control.stats_info-sw_stat.mem_freed 
@@ -6700,18 +6700,18 @@ static int s2io_add_isr(struct s2io_nic 
struct net_device *dev = sp-dev;
int err = 0;
 
-   if (sp-intr_type == MSI_X)
+   if (sp-config.intr_type == MSI_X)
ret = s2io_enable_msi_x(sp);
if (ret) {
DBG_PRINT(ERR_DBG, %s: Defaulting to INTA\n, dev-name);
-   sp-intr_type = INTA;
+   sp-config.intr_type = INTA;
}
 
/* Store the values of the MSIX table in the struct s2io_nic structure 
*/
store_xmsi_data(sp);
 
/* After proper initialization of H/W, register ISR */
-   if (sp-intr_type == MSI_X) {
+   if (sp-config.intr_type == MSI_X) {
int i, msix_tx_cnt=0,msix_rx_cnt=0;
 
for (i=1; (sp-s2io_entries[i].in_use == MSIX_FLG); i++) {
@@ -6763,7 +6763,7 @@ static int s2io_add_isr(struct s2io_nic 
printk(MSI-X-TX %d entries enabled\n,msix_tx_cnt);
printk(MSI-X-RX %d entries enabled\n,msix_rx_cnt);
}
-   if (sp-intr_type == INTA) {
+   if (sp-config.intr_type == INTA) {
err = request_irq((int) sp-pdev-irq, s2io_isr, IRQF_SHARED,
sp-name, dev);
if (err) {
@@ -6780,7 +6780,7 @@ static void s2io_rem_isr(struct s2io_nic
struct net_device *dev = sp-dev;
struct swStat *stats = sp-mac_control.stats_info-sw_stat;
 
-   if (sp-intr_type == MSI_X) {
+   if (sp-config.intr_type == MSI_X) {
int i;
u16 msi_control;
 
@@ -6953,7 +6953,7 @@ static int s2io_card_up(struct s2io_nic 
 
/* Add interrupt service routine */
if (s2io_add_isr(sp) != 0) {
-   if (sp-intr_type == MSI_X)
+   if (sp-config.intr_type == MSI_X)
s2io_rem_isr(sp);
s2io_reset

[PATCH 2.6.24 4/5]S2io: Check for device state before handling traffic

2007-09-06 Thread Sivakumar Subramani
- Added check to return from the traffic handling function, if the card status
  is DOWN.
- Implemented Jeff's comments on incorrect return value in s2io_poll function.

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
Signed-off-by: Santosh Rastapur [EMAIL PROTECTED]
Signed-off-by: Ramkrishna Vepa [EMAIL PROTECTED]
---
diff -urpN patch_3/drivers/net/s2io.c patch_4/drivers/net/s2io.c
--- patch_3/drivers/net/s2io.c  2007-09-05 13:50:34.0 +0530
+++ patch_4/drivers/net/s2io.c  2007-09-05 14:11:17.0 +0530
@@ -130,6 +130,11 @@ static inline int rx_buffer_level(struct
return 0;
 }
 
+static inline int is_s2io_card_up(const struct s2io_nic * sp)
+{
+   return test_bit(__S2IO_STATE_CARD_UP, sp-state);
+}
+
 /* Ethtool related variables and Macros. */
 static char s2io_gstrings[][ETH_GSTRING_LEN] = {
Register test\t(offline),
@@ -2710,6 +2715,12 @@ static int s2io_poll(struct net_device *
int i;
 
atomic_inc(nic-isr_cnt);
+
+   if (!is_s2io_card_up(nic)) {
+   atomic_dec(nic-isr_cnt);
+   return 0;
+   }
+
mac_control = nic-mac_control;
config = nic-config;
 
@@ -2845,12 +2856,6 @@ static void rx_intr_handler(struct ring_
struct RxD3* rxdp3;
 
spin_lock(nic-rx_lock);
-   if (atomic_read(nic-card_state) == CARD_DOWN) {
-   DBG_PRINT(INTR_DBG, %s: %s going down for reset\n,
- __FUNCTION__, dev-name);
-   spin_unlock(nic-rx_lock);
-   return;
-   }
 
get_info = ring_data-rx_curr_get_info;
get_block = get_info.block_index;
@@ -3994,7 +3999,7 @@ static int s2io_xmit(struct sk_buff *skb
 }
 
spin_lock_irqsave(sp-tx_lock, flags);
-   if (atomic_read(sp-card_state) == CARD_DOWN) {
+   if (!is_s2io_card_up(sp)) {
DBG_PRINT(TX_DBG, %s: Card going down for reset\n,
  dev-name);
spin_unlock_irqrestore(sp-tx_lock, flags);
@@ -4188,6 +4193,11 @@ static irqreturn_t s2io_msix_ring_handle
 
atomic_inc(sp-isr_cnt);
 
+   if (!is_s2io_card_up(sp)) {
+   atomic_dec(sp-isr_cnt);
+   return IRQ_HANDLED;
+   }
+
rx_intr_handler(ring);
s2io_chk_rx_buffers(sp, ring-ring_no);
 
@@ -4201,6 +4211,12 @@ static irqreturn_t s2io_msix_fifo_handle
struct s2io_nic *sp = fifo-nic;
 
atomic_inc(sp-isr_cnt);
+
+   if (!is_s2io_card_up(sp)) {
+   atomic_dec(sp-isr_cnt);
+   return IRQ_HANDLED;
+   }
+
tx_intr_handler(fifo);
atomic_dec(sp-isr_cnt);
return IRQ_HANDLED;
@@ -4308,7 +4324,7 @@ static void s2io_handle_errors(void * de
struct swStat *sw_stat = sp-mac_control.stats_info-sw_stat;
struct xpakStat *stats = sp-mac_control.stats_info-xpak_stat;
 
-   if (unlikely(atomic_read(sp-card_state) == CARD_DOWN))
+   if (!is_s2io_card_up(sp))
return;
 
if (pci_channel_offline(sp-pdev))
@@ -4579,6 +4595,12 @@ static irqreturn_t s2io_isr(int irq, voi
return IRQ_NONE;
 
atomic_inc(sp-isr_cnt);
+
+   if (!is_s2io_card_up(sp)) {
+   atomic_dec(sp-isr_cnt);
+   return IRQ_NONE;
+   }
+
mac_control = sp-mac_control;
config = sp-config;
 
@@ -4667,7 +4689,7 @@ static void s2io_updt_stats(struct s2io_
u64 val64;
int cnt = 0;
 
-   if (atomic_read(sp-card_state) == CARD_UP) {
+   if (is_s2io_card_up(sp)) {
/* Apprx 30us on a 133 MHz bus */
val64 = SET_UPDT_CLICKS(10) |
STAT_CFG_ONE_SHOT_EN | STAT_CFG_STAT_EN;
@@ -6463,7 +6485,7 @@ static void s2io_set_link(struct work_st
if (!netif_running(dev))
goto out_unlock;
 
-   if (test_and_set_bit(0, (nic-link_state))) {
+   if (test_and_set_bit(__S2IO_STATE_LINK_TASK, (nic-state))) {
/* The card is being reset, no point doing anything */
goto out_unlock;
}
@@ -6519,7 +6541,7 @@ static void s2io_set_link(struct work_st
writeq(val64, bar0-adapter_control);
s2io_link(nic, LINK_DOWN);
}
-   clear_bit(0, (nic-link_state));
+   clear_bit(__S2IO_STATE_LINK_TASK, (nic-state));
 
 out_unlock:
rtnl_unlock();
@@ -6828,10 +6850,10 @@ static void do_s2io_card_down(struct s2i
 
del_timer_sync(sp-alarm_timer);
/* If s2io_set_link task is executing, wait till it completes. */
-   while (test_and_set_bit(0, (sp-link_state))) {
+   while (test_and_set_bit(__S2IO_STATE_LINK_TASK, (sp-state))) {
msleep(50);
}
-   atomic_set(sp-card_state, CARD_DOWN);
+   clear_bit(__S2IO_STATE_CARD_UP, sp-state);
 
/* disable Tx and Rx traffic on the NIC */
if (do_io)
@@ -6882,7 +6904,7 @@ static void do_s2io_card_down(struct s2i
free_rx_buffers(sp

RE: drivers/net/tokenring/3c359.c

2007-08-16 Thread Sivakumar Subramani
What exactly the difference between kzalloc and kcalloc? From the
definition, I could see that kcalloc should be used for array
allocation. But I could see kzalloc is used for allocation arrays as in
the below patch.

Any coding standard (or) developers can use kzalloc and kcalloc as per
their coding practice??

Thanks,
~Siva
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Jeff Garzik
Sent: Tuesday, August 14, 2007 11:20 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; netdev@vger.kernel.org; [EMAIL PROTECTED];
Linux Kernel; kernel-janitors
Subject: Re: drivers/net/tokenring/3c359.c

Surya Prabhakar N wrote:
 Hi,
Replacing kmalloc with kzalloc and cleaning up memset in 
 drivers/net/tokenring/3c359.c
 
 
 Signed-off-by: Surya Prabhakar [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


[PATCH 2.6.24]S2io: Default to IntA interrupt type when there are less than 4 CPUs in the system.

2007-08-09 Thread Sivakumar Subramani
- Default to IntA interrupt type when there are less than 4 CPUs in the system.

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
Signed-off-by: Ramkrishna Vepa [EMAIL PROTECTED]
---
diff -Nurp 2.0.26.2/drivers/net/s2io.c 2.0.26.3/drivers/net/s2io.c
--- 2.0.26.2/drivers/net/s2io.c 2007-08-07 13:39:45.0 -0700
+++ 2.0.26.3/drivers/net/s2io.c 2007-08-07 15:51:45.0 -0700
@@ -84,7 +84,7 @@
 #include s2io.h
 #include s2io-regs.h
 
-#define DRV_VERSION 2.0.26.2
+#define DRV_VERSION 2.0.26.3
 
 /* S2io Driver name  version. */
 static char s2io_driver_name[] = Neterion;
@@ -452,7 +452,7 @@ S2IO_PARM_INT(l3l4hdr_size, 128);
 /* Frequency of Rx desc syncs expressed as power of 2 */
 S2IO_PARM_INT(rxsync_frequency, 3);
 /* Interrupt type. Values can be 0(INTA), 2(MSI_X) */
-S2IO_PARM_INT(intr_type, 2);
+S2IO_PARM_INT(intr_type, DEF_MSI_X);
 /* Large receive offload feature */
 S2IO_PARM_INT(lro, 0);
 /* Max pkts to be aggregated by LRO at one time. If not specified,
@@ -7671,10 +7671,11 @@ static int s2io_verify_parm(struct pci_d
if (*dev_intr_type != INTA)
napi = 0;
 
-   if ((*dev_intr_type != INTA)  (*dev_intr_type != MSI_X)) {
+   if ((intr_type != INTA)  (intr_type != MSI_X)) {
DBG_PRINT(ERR_DBG, s2io: Wrong intr_type requested. 
  Defaulting to INTA\n);
*dev_intr_type = INTA;
+   intr_type = INTA;
}
 
if ((*dev_intr_type == MSI_X) 
@@ -7752,8 +7753,19 @@ s2io_init_nic(struct pci_dev *pdev, cons
struct mac_info *mac_control;
struct config_param *config;
int mode;
-   u8 dev_intr_type = intr_type;
+   u8 dev_intr_type;
+   int no_cpus = 1;
 
+   no_cpus = num_online_cpus();
+   if(DEF_MSI_X == intr_type) {
+   /* Don't enable MSI-X if there are less than 4 CPUs */
+   if(no_cpus  4)
+   intr_type = INTA;
+   else
+   intr_type = MSI_X;
+   }
+
+   dev_intr_type = intr_type;
if ((ret = s2io_verify_parm(pdev, dev_intr_type)))
return ret;
 
diff -Nurp 2.0.26.2/drivers/net/s2io.h 2.0.26.3/drivers/net/s2io.h
--- 2.0.26.2/drivers/net/s2io.h 2007-08-07 13:39:45.0 -0700
+++ 2.0.26.3/drivers/net/s2io.h 2007-08-07 13:40:18.0 -0700
@@ -433,6 +433,7 @@ struct config_param {
u64 tx_intr_type;
 #define INTA   0
 #define MSI_X  2
+#defineDEF_MSI_X   99
u8 intr_type;
u8 napi;
 

-
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.23 1/3]S2IO: Making MSIX as default intr_type

2007-08-06 Thread Sivakumar Subramani
- Making MSIX as default intr_type
- Driver will test MSI-X by issuing test MSI-X vector and if fails it will
  fallback to INTA

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
Signed-off-by: Ramkrishna Vepa [EMAIL PROTECTED]
---
diff -urpN org/drivers/net/s2io.c patch1/drivers/net/s2io.c
--- org/drivers/net/s2io.c  2007-07-31 10:50:04.0 +0530
+++ patch1/drivers/net/s2io.c   2007-07-31 11:04:50.0 +0530
@@ -37,7 +37,7 @@
  * tx_fifo_len: This too is an array of 8. Each element defines the number of
  * Tx descriptors that can be associated with each corresponding FIFO.
  * intr_type: This defines the type of interrupt. The values can be 0(INTA),
- * 2(MSI_X). Default value is '0(INTA)'
+ * 2(MSI_X). Default value is '2(MSI_X)'
  * lro: Specifies whether to enable Large Receive Offload (LRO) or not.
  * Possible values '1' for enable '0' for disable. Default is '0'
  * lro_max_pkts: This parameter defines maximum number of packets can be
@@ -428,7 +428,7 @@ S2IO_PARM_INT(l3l4hdr_size, 128);
 /* Frequency of Rx desc syncs expressed as power of 2 */
 S2IO_PARM_INT(rxsync_frequency, 3);
 /* Interrupt type. Values can be 0(INTA), 2(MSI_X) */
-S2IO_PARM_INT(intr_type, 0);
+S2IO_PARM_INT(intr_type, 2);
 /* Large receive offload feature */
 S2IO_PARM_INT(lro, 0);
 /* Max pkts to be aggregated by LRO at one time. If not specified,
@@ -3781,6 +3781,59 @@ static int s2io_enable_msi_x(struct s2io
return 0;
 }
 
+/* Handle software interrupt used during MSI(X) test */
+static irqreturn_t __devinit s2io_test_intr(int irq, void *dev_id)
+{
+   struct s2io_nic *sp = dev_id;
+
+   sp-msi_detected = 1;
+   wake_up(sp-msi_wait);
+
+   return IRQ_HANDLED;
+}
+
+/* Test interrupt path by forcing a a software IRQ */
+static int __devinit s2io_test_msi(struct s2io_nic *sp)
+{
+   struct pci_dev *pdev = sp-pdev;
+   struct XENA_dev_config __iomem *bar0 = sp-bar0;
+   int err;
+   u64 val64, saved64;
+
+   err = request_irq(sp-entries[1].vector, s2io_test_intr, 0,
+   sp-name, sp);
+   if (err) {
+   DBG_PRINT(ERR_DBG, %s: PCI %s: cannot assign irq %d\n,
+  sp-dev-name, pci_name(pdev), pdev-irq);
+   return err;
+   }
+
+   init_waitqueue_head (sp-msi_wait);
+   sp-msi_detected = 0;
+
+   saved64 = val64 = readq(bar0-scheduled_int_ctrl);
+   val64 |= SCHED_INT_CTRL_ONE_SHOT;
+   val64 |= SCHED_INT_CTRL_TIMER_EN;
+   val64 |= SCHED_INT_CTRL_INT2MSI(1);
+   writeq(val64, bar0-scheduled_int_ctrl);
+
+   wait_event_timeout(sp-msi_wait, sp-msi_detected, HZ/10);
+
+   if (!sp-msi_detected) {
+   /* MSI(X) test failed, go back to INTx mode */
+   DBG_PRINT(ERR_DBG, %s: PCI %s: No interrupt was generated
+   using MSI(X) during test\n, sp-dev-name,
+   pci_name(pdev));
+
+   err = -EOPNOTSUPP;
+   }
+
+   free_irq(sp-entries[1].vector, sp);
+
+   writeq(saved64, bar0-scheduled_int_ctrl);
+
+   return err;
+}
 /* * *
  * Functions defined below concern the OS part of the driver *
  * * */
@@ -3809,6 +3862,42 @@ static int s2io_open(struct net_device *
netif_carrier_off(dev);
sp-last_link_state = 0;
 
+   if (sp-intr_type == MSI_X) {
+   int ret = s2io_enable_msi_x(sp);
+
+   if (!ret) {
+   u16 msi_control;
+
+   ret = s2io_test_msi(sp);
+
+   /* rollback MSI-X, will re-enable during add_isr() */
+   kfree(sp-entries);
+   sp-mac_control.stats_info-sw_stat.mem_freed +=
+   (MAX_REQUESTED_MSI_X *
+   sizeof(struct msix_entry));
+   kfree(sp-s2io_entries);
+   sp-mac_control.stats_info-sw_stat.mem_freed +=
+   (MAX_REQUESTED_MSI_X *
+   sizeof(struct s2io_msix_entry));
+   sp-entries = NULL;
+   sp-s2io_entries = NULL;
+
+   pci_read_config_word(sp-pdev, 0x42, msi_control);
+   msi_control = 0xFFFE; /* Disable MSI */
+   pci_write_config_word(sp-pdev, 0x42, msi_control);
+
+   pci_disable_msix(sp-pdev);
+
+   }
+   if (ret) {
+
+   DBG_PRINT(ERR_DBG,
+ %s: MSI-X requested but failed to enable\n,
+ dev-name);
+   sp-intr_type = INTA;
+   }
+   }
+
/* Initialize H/W and enable interrupts */
err = s2io_card_up(sp);
if (err) {
diff -urpN org/drivers/net/s2io.h patch1/drivers/net/s2io.h
--- org/drivers

[PATCH 2.6.23 2/3]S2IO: Fixes in MSIX related code.

2007-08-06 Thread Sivakumar Subramani
- Calling store_xmsi_data to store the MSI-X datas during initialization
  in s2io-init_nic function
- Disabling NAPI when MSI-X is enabled
- Freeing sp-entries and sp-s2io_entries in s2io_rem_isr

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
Signed-off-by: Ramkrishna Vepa [EMAIL PROTECTED]
---
diff -urpN patch1/drivers/net/s2io.c patch2/drivers/net/s2io.c
--- patch1/drivers/net/s2io.c   2007-07-31 11:04:50.0 +0530
+++ patch2/drivers/net/s2io.c   2007-08-02 16:51:57.0 +0530
@@ -3898,6 +3898,12 @@ static int s2io_open(struct net_device *
}
}
 
+   /* NAPI doesn't work well with MSI(X) */
+if (sp-intr_type != INTA) {
+   if(sp-config.napi)
+   sp-config.napi = 0;
+   }
+
/* Initialize H/W and enable interrupts */
err = s2io_card_up(sp);
if (err) {
@@ -6472,6 +6478,7 @@ static void s2io_rem_isr(struct s2io_nic
 {
int cnt = 0;
struct net_device *dev = sp-dev;
+   struct swStat *stats = sp-mac_control.stats_info-sw_stat;
 
if (sp-intr_type == MSI_X) {
int i;
@@ -6484,6 +6491,16 @@ static void s2io_rem_isr(struct s2io_nic
 
free_irq(vector, arg);
}
+
+   kfree(sp-entries);
+   stats-mem_freed +=
+   (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
+   kfree(sp-s2io_entries);
+   stats-mem_freed +=
+   (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
+   sp-entries = NULL;
+   sp-s2io_entries = NULL;
+
pci_read_config_word(sp-pdev, 0x42, msi_control);
msi_control = 0xFFFE; /* Disable MSI */
pci_write_config_word(sp-pdev, 0x42, msi_control);
@@ -7379,6 +7396,8 @@ s2io_init_nic(struct pci_dev *pdev, cons
dev-addr_len = ETH_ALEN;
memcpy(dev-dev_addr, sp-def_mac_addr, ETH_ALEN);
 
+/* Store the values of the MSIX table in the s2io_nic structure */
+   store_xmsi_data(sp);
/* reset Nic and bring it to known state */
s2io_reset(sp);
 
diff -urpN patch1/drivers/net/s2io.h patch2/drivers/net/s2io.h
--- patch1/drivers/net/s2io.h   2007-07-31 10:47:06.0 +0530
+++ patch2/drivers/net/s2io.h   2007-07-31 10:57:35.0 +0530
@@ -415,6 +415,7 @@ struct config_param {
 #define INTA   0
 #define MSI_X  2
u8 intr_type;
+   u8 napi;
 
/* Specifies if Tx Intr is UTILZ or PER_LIST type. */
 

-
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.23 3/3]S2IO: Fixed Link LED issue when MSI-X is enabled

2007-08-06 Thread Sivakumar Subramani
-Fixed Link LED issue when MSI-X is enabled.

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
Signed-off-by: Ramkrishna Vepa [EMAIL PROTECTED]
---
diff -urpN patch2/drivers/net/s2io.c patch3/drivers/net/s2io.c
--- patch2/drivers/net/s2io.c   2007-08-02 17:00:36.0 +0530
+++ patch3/drivers/net/s2io.c   2007-08-02 16:59:40.0 +0530
@@ -84,7 +84,7 @@
 #include s2io.h
 #include s2io-regs.h
 
-#define DRV_VERSION 2.0.25.1
+#define DRV_VERSION 2.0.26.1
 
 /* S2io Driver name  version. */
 static char s2io_driver_name[] = Neterion;
@@ -6205,13 +6205,10 @@ static void s2io_set_link(struct work_st
netif_stop_queue(dev);
}
}
-   val64 = readq(bar0-adapter_status);
-   if (!LINK_IS_UP(val64)) {
-   DBG_PRINT(ERR_DBG, %s:, dev-name);
-   DBG_PRINT(ERR_DBG,  Link down after enabling );
-   DBG_PRINT(ERR_DBG, device \n);
-   } else
-   s2io_link(nic, LINK_UP);
+   val64 = readq(bar0-adapter_control);
+   val64 |= ADAPTER_LED_ON;
+   writeq(val64, bar0-adapter_control);
+   s2io_link(nic, LINK_UP);
} else {
if (CARDS_WITH_FAULTY_LINK_INDICATORS(nic-device_type,
  subid)) {
@@ -6220,6 +6217,10 @@ static void s2io_set_link(struct work_st
writeq(val64, bar0-gpio_control);
val64 = readq(bar0-gpio_control);
}
+   /* turn off LED */
+   val64 = readq(bar0-adapter_control);
+   val64 = val64 (~ADAPTER_LED_ON);
+   writeq(val64, bar0-adapter_control);
s2io_link(nic, LINK_DOWN);
}
clear_bit(0, (nic-link_state));

-
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.22 1/4]S2IO: Adding checks to check the return value of pci mapping function

2007-07-12 Thread Sivakumar Subramani
Hi Jeff,

We have the fixed the review comments as part of Patch2 and resubmitted
it again yesterday.

Thanks,
~Siva 

-Original Message-
From: Jeff Garzik [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 02, 2007 5:51 PM
To: Veena Parat
Cc: netdev@vger.kernel.org; Leonid Grossman; Ramkrishna Vepa; Rastapur
Santosh; Sivakumar Subramani; Sreenivasa Honnur; Alicia Pena; Sriram
Rapuru
Subject: Re: [PATCH 2.6.22 1/4]S2IO: Adding checks to check the return
value of pci mapping function

Veena Parat wrote:
 Adding checks to check the return value of pci mapping function
 
 Signed-off-by: Veena Parat [EMAIL PROTECTED]
 ---
 diff -urpN org/drivers/net/s2io.c patch_1/drivers/net/s2io.c
 --- org/drivers/net/s2io.c2007-05-17 20:35:39.0 +0530
 +++ patch_1/drivers/net/s2io.c2007-05-17 20:35:55.0
+0530
 @@ -282,6 +282,7 @@ static char ethtool_driver_stats_keys[][
   (lro_flush_due_to_max_pkts),
   (lro_avg_aggr_pkts),
   (mem_alloc_fail_cnt),
 + {pci_map_fail_cnt},
   (watchdog_timer_cnt),
   (mem_allocated),
   (mem_freed),
 @@ -2247,10 +2248,19 @@ static int fill_rxd_3buf(struct s2io_nic
   (nic-pdev, skb-data, l3l4hdr_size + 4,
   PCI_DMA_FROMDEVICE);
  
 + if struct RxD3*)rxdp)-Buffer1_ptr == 0) ||
 + (((struct RxD3*)rxdp)-Buffer1_ptr == DMA_ERROR_CODE)) {
 + nic-mac_control.stats_info-sw_stat.pci_map_fail_cnt++;
 + return -ENOMEM;
 + }
 +
   /* skb_shinfo(skb)-frag_list will have L4 data payload */
   skb_shinfo(skb)-frag_list = dev_alloc_skb(dev-mtu +
ALIGN_SIZE);
   if (skb_shinfo(skb)-frag_list == NULL) {

nic-mac_control.stats_info-sw_stat.mem_alloc_fail_cnt++;
 + pci_unmap_single
 + (nic-pdev, (dma_addr_t)skb-data, l3l4hdr_size
+ 4,
 + PCI_DMA_FROMDEVICE);
   DBG_PRINT(INFO_DBG, %s: dev_alloc_skb failed\n ,
dev-name);
   return -ENOMEM ;
   }
 @@ -2267,6 +2277,11 @@ static int fill_rxd_3buf(struct s2io_nic
   ((struct RxD3*)rxdp)-Buffer2_ptr = pci_map_single(nic-pdev,
   frag_list-data, dev-mtu,
   PCI_DMA_FROMDEVICE);
 + if struct RxD3*)rxdp)-Buffer2_ptr == 0) ||
 + (((struct RxD3*)rxdp)-Buffer2_ptr == DMA_ERROR_CODE)) {
 + nic-mac_control.stats_info-sw_stat.pci_map_fail_cnt++;
 + return -ENOMEM;
 + }
   rxdp-Control_2 |= SET_BUFFER1_SIZE_3(l3l4hdr_size + 4);
   rxdp-Control_2 |= SET_BUFFER2_SIZE_3(dev-mtu);
  
 @@ -2399,6 +2414,16 @@ static int fill_rx_buffers(struct s2io_n
   ((struct RxD1*)rxdp)-Buffer0_ptr =
pci_map_single
   (nic-pdev, skb-data, size - NET_IP_ALIGN,
   PCI_DMA_FROMDEVICE);
 + if struct RxD1*)rxdp)-Buffer0_ptr == 0) ||
 + (((struct RxD1*)rxdp)-Buffer0_ptr == 
 + DMA_ERROR_CODE)) {
 + nic-mac_control.stats_info-sw_stat.
 + pci_map_fail_cnt++;
 +
nic-mac_control.stats_info-sw_stat.mem_freed
 + += skb-truesize;
 + dev_kfree_skb_irq(skb);
 + return -ENOMEM;
 + }
   rxdp-Control_2 = 
   SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN);
  

please provide a prep patch that eliminates all these inline casts. 
Create temporary variables or whatever you need to do to convert the
messy and unreadable (((struct RxD1*)rxdp)-Buffer0_ptr into
desc-Buffer0_ptr.

otherwise looks OK

-
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.22 1/4]S2IO: Adding checks to check the return value of pci mapping function

2007-06-29 Thread Sivakumar Subramani
Hi Jeff,

Any update on these patch submission? Is it in queue? 

Thanks,
~Siva

-Original Message-
From: Veena Parat [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 19, 2007 3:27 PM
To: netdev@vger.kernel.org; [EMAIL PROTECTED]
Cc: Leonid Grossman; Ramkrishna Vepa; Rastapur Santosh; Sivakumar
Subramani; Sreenivasa Honnur; Alicia Pena; Sriram Rapuru
Subject: [PATCH 2.6.22 1/4]S2IO: Adding checks to check the return value
of pci mapping function

Adding checks to check the return value of pci mapping function 

Signed-off-by: Veena Parat [EMAIL PROTECTED]
---
diff -urpN org/drivers/net/s2io.c patch_1/drivers/net/s2io.c
--- org/drivers/net/s2io.c  2007-05-17 20:35:39.0 +0530
+++ patch_1/drivers/net/s2io.c  2007-05-17 20:35:55.0 +0530
@@ -282,6 +282,7 @@ static char ethtool_driver_stats_keys[][
(lro_flush_due_to_max_pkts),
(lro_avg_aggr_pkts),
(mem_alloc_fail_cnt),
+   {pci_map_fail_cnt},
(watchdog_timer_cnt),
(mem_allocated),
(mem_freed),
@@ -2247,10 +2248,19 @@ static int fill_rxd_3buf(struct s2io_nic
(nic-pdev, skb-data, l3l4hdr_size + 4,
PCI_DMA_FROMDEVICE);
 
+   if struct RxD3*)rxdp)-Buffer1_ptr == 0) ||
+   (((struct RxD3*)rxdp)-Buffer1_ptr == DMA_ERROR_CODE)) {
+   nic-mac_control.stats_info-sw_stat.pci_map_fail_cnt++;
+   return -ENOMEM;
+   }
+
/* skb_shinfo(skb)-frag_list will have L4 data payload */
skb_shinfo(skb)-frag_list = dev_alloc_skb(dev-mtu +
ALIGN_SIZE);
if (skb_shinfo(skb)-frag_list == NULL) {
 
nic-mac_control.stats_info-sw_stat.mem_alloc_fail_cnt++;
+   pci_unmap_single
+   (nic-pdev, (dma_addr_t)skb-data, l3l4hdr_size
+ 4,
+   PCI_DMA_FROMDEVICE);
DBG_PRINT(INFO_DBG, %s: dev_alloc_skb failed\n ,
dev-name);
return -ENOMEM ;
}
@@ -2267,6 +2277,11 @@ static int fill_rxd_3buf(struct s2io_nic
((struct RxD3*)rxdp)-Buffer2_ptr = pci_map_single(nic-pdev,
frag_list-data, dev-mtu,
PCI_DMA_FROMDEVICE);
+   if struct RxD3*)rxdp)-Buffer2_ptr == 0) ||
+   (((struct RxD3*)rxdp)-Buffer2_ptr == DMA_ERROR_CODE)) {
+   nic-mac_control.stats_info-sw_stat.pci_map_fail_cnt++;
+   return -ENOMEM;
+   }
rxdp-Control_2 |= SET_BUFFER1_SIZE_3(l3l4hdr_size + 4);
rxdp-Control_2 |= SET_BUFFER2_SIZE_3(dev-mtu);
 
@@ -2399,6 +2414,16 @@ static int fill_rx_buffers(struct s2io_n
((struct RxD1*)rxdp)-Buffer0_ptr =
pci_map_single
(nic-pdev, skb-data, size - NET_IP_ALIGN,
PCI_DMA_FROMDEVICE);
+   if struct RxD1*)rxdp)-Buffer0_ptr == 0) ||
+   (((struct RxD1*)rxdp)-Buffer0_ptr == 
+   DMA_ERROR_CODE)) {
+   nic-mac_control.stats_info-sw_stat.
+   pci_map_fail_cnt++;
+
nic-mac_control.stats_info-sw_stat.mem_freed
+   += skb-truesize;
+   dev_kfree_skb_irq(skb);
+   return -ENOMEM;
+   }
rxdp-Control_2 = 
SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN);
 
@@ -2430,14 +2455,19 @@ static int fill_rx_buffers(struct s2io_n
skb-data = (void *) (unsigned long)tmp;
skb_reset_tail_pointer(skb);
 
-   if (!(((struct RxD3*)rxdp)-Buffer0_ptr))
-   ((struct RxD3*)rxdp)-Buffer0_ptr =
-  pci_map_single(nic-pdev, ba-ba_0,
BUF0_LEN,
-  PCI_DMA_FROMDEVICE);
-   else
-
pci_dma_sync_single_for_device(nic-pdev,
-   (dma_addr_t) ((struct
RxD3*)rxdp)-Buffer0_ptr,
-   BUF0_LEN, PCI_DMA_FROMDEVICE);
+   ((struct RxD3*)rxdp)-Buffer0_ptr =
+   pci_map_single(nic-pdev, ba-ba_0,
BUF0_LEN,
+   PCI_DMA_FROMDEVICE);
+   if struct RxD3*)rxdp)-Buffer0_ptr == 0) ||
+   (((struct RxD3*)rxdp)-Buffer0_ptr == 
+   DMA_ERROR_CODE)) {
+   nic-mac_control.stats_info-sw_stat.
+   pci_map_fail_cnt++;
+
nic-mac_control.stats_info-sw_stat.mem_freed
+   += skb-truesize;
+   dev_kfree_skb_irq(skb);
+   return -ENOMEM;
+   }
rxdp-Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN

RE: 2.6.22: ERROR: __ucmpdi2 [drivers/net/s2io.ko] undefined!

2007-06-21 Thread Sivakumar Subramani
Hi,

We will include this fix in next set of patch submission. Thanks for the
fix.

Thanks,
~Siva 
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Olaf Hering
Sent: Wednesday, June 20, 2007 2:11 AM
To: Stephen Hemminger
Cc: [EMAIL PROTECTED]; netdev@vger.kernel.org
Subject: Re: 2.6.22: ERROR: __ucmpdi2 [drivers/net/s2io.ko] undefined!

On Tue, Jun 19, Stephen Hemminger wrote:

 On Tue, 19 Jun 2007 21:02:53 +0200
 Olaf Hering [EMAIL PROTECTED] wrote:
 
  
  What happend to __ucmpdi2 from David Woodhouse?
  google has a few hits about stuff like this on 32bit powerpc with
gcc 4.1.2:
  
  ERROR: __ucmpdi2 [drivers/net/s2io.ko] undefined!
  
  using the drivers/net/s2io* files from 2.6.21 with 2.6.22-rc5 fixes 
  the compile.
  
  25805dcf9d83098cf5492117ad2669cd14cc9b24 adds two u64 = 48 
  followed by a switch statement (line 2889 and 6816).
 
 Probably the switch(err) { needs a cast to a smaller type (like u8).

This change removes the calls to __ucmpdi2.

---
 drivers/net/s2io.c |   16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -2868,6 +2868,7 @@ static void tx_intr_handler(struct fifo_
struct tx_curr_get_info get_info, put_info;
struct sk_buff *skb;
struct TxD *txdlp;
+   u8 err_mask;
 
get_info = fifo_data-tx_curr_get_info;
memcpy(put_info, fifo_data-tx_curr_put_info,
sizeof(put_info)); @@ -2886,8 +2887,8 @@ static void
tx_intr_handler(struct fifo_
}
 
/* update t_code statistics */
-   err = 48;
-   switch(err) {
+   err_mask = err  48;
+   switch(err_mask) {
case 2:
 
nic-mac_control.stats_info-sw_stat.
 
tx_buf_abort_cnt++;
@@ -6805,6 +6806,7 @@ static int rx_osm_handler(struct ring_in
u16 l3_csum, l4_csum;
unsigned long long err = rxdp-Control_1  RXD_T_CODE;
struct lro *lro;
+   u8 err_mask;
 
skb-dev = dev;
 
@@ -6813,8 +6815,8 @@ static int rx_osm_handler(struct ring_in
if (err  0x1) {
 
sp-mac_control.stats_info-sw_stat.parity_err_cnt++;
}
-   err = 48;
-   switch(err) {
+   err_mask = err  48;
+   switch(err_mask) {
case 1:
sp-mac_control.stats_info-sw_stat.
rx_parity_err_cnt++;
@@ -6867,9 +6869,9 @@ static int rx_osm_handler(struct ring_in
* Note that in this case, since checksum will be
incorrect,
* stack will validate the same.
*/
-   if (err != 0x5) {
-   DBG_PRINT(ERR_DBG, %s: Rx error Value:
0x%llx\n,
-   dev-name, err);
+   if (err_mask != 0x5) {
+   DBG_PRINT(ERR_DBG, %s: Rx error Value: 0x%x\n,
+   dev-name, err_mask);
sp-stats.rx_crc_errors++;
sp-mac_control.stats_info-sw_stat.mem_freed 
+= skb-truesize;
-
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] s2io: don't run MSI handlers if device is offline.

2007-05-22 Thread Sivakumar Subramani
Fix looks good. No comments.
~Siva 

-Original Message-
From: Linas Vepstas [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 23, 2007 4:20 AM
To: Jeff Garzik; Andrew Morton
Cc: [EMAIL PROTECTED]; netdev@vger.kernel.org;
Ramkrishna Vepa; Sivakumar Subramani; Sreenivasa Honnur; Rastapur
Santosh; Wen Xiong
Subject: [PATCH] s2io: don't run MSI handlers if device is offline.


Don't run any of the MSI handlers if the channel is off; also don't
gather device statatistics. Also, netif_wake not needed, per suggestions
from Sivakumar Subramani [EMAIL PROTECTED].

Signed-off-by: Linas Vepstas [EMAIL PROTECTED]
Cc: Ramkrishna Vepa [EMAIL PROTECTED]
Cc: Sivakumar Subramani [EMAIL PROTECTED]
Cc: Sreenivasa Honnur [EMAIL PROTECTED]
Cc: Rastapur Santosh [EMAIL PROTECTED]
Cc: Wen Xiong [EMAIL PROTECTED]


diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index
e46e164..871c37c 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -4202,6 +4202,9 @@ static irqreturn_t s2io_msi_handle(int i
struct mac_info *mac_control;
struct config_param *config;
 
+   if (pci_channel_offline(sp-pdev))
+   return IRQ_NONE;
+
atomic_inc(sp-isr_cnt);
mac_control = sp-mac_control;
config = sp-config;
@@ -4232,6 +4235,9 @@ static irqreturn_t s2io_msix_ring_handle
struct ring_info *ring = (struct ring_info *)dev_id;
struct s2io_nic *sp = ring-nic;
 
+   if (pci_channel_offline(sp-pdev))
+   return IRQ_NONE;
+
atomic_inc(sp-isr_cnt);
 
rx_intr_handler(ring);
@@ -4246,6 +4252,9 @@ static irqreturn_t s2io_msix_fifo_handle
struct fifo_info *fifo = (struct fifo_info *)dev_id;
struct s2io_nic *sp = fifo-nic;
 
+   if (pci_channel_offline(sp-pdev))
+   return IRQ_NONE;
+
atomic_inc(sp-isr_cnt);
tx_intr_handler(fifo);
atomic_dec(sp-isr_cnt);
@@ -4428,6 +4437,9 @@ static void s2io_updt_stats(struct s2io_
u64 val64;
int cnt = 0;
 
+   if (pci_channel_offline(sp-pdev))
+   return;
+
if (atomic_read(sp-card_state) == CARD_UP) {
/* Apprx 30us on a 133 MHz bus */
val64 = SET_UPDT_CLICKS(10) |
@@ -8122,5 +8134,4 @@ static void s2io_io_resume(struct pci_de
}
 
netif_device_attach(netdev);
-   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


RE: [PATCH 1/2] s2io: add PCI error recovery support

2007-05-18 Thread Sivakumar Subramani
Hi,

Fix looks good. I have couple of comments,

1) Return from s2io_updt_stats function if the PCI bus is offline
(pci_channel_offline). 
 if (pci_channel_offline(pdev))
return;

2) No Need to call netif_wake_queue() in s2io_io_resume as
netif_device_attach() will take care of calling it.

3) We need to return from s2io_msix_ring_handle(),
s2io_msix_fifo_handle(), s2io_msi_handle() if the PCI channel is
offline. Some thing similary to the below condition that is added in the
s2io_isr()

 -4117,6 +4129,10 @@ static irqreturn_t s2io_isr(int irq, voi
struct mac_info *mac_control;
struct config_param *config;

+   /* Pretend we handled any irq's from a disconnected card */
+   if (pci_channel_offline(sp-pdev))
+   return IRQ_NONE;

Thanks,
~Siva

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Linas Vepstas
Sent: Tuesday, May 15, 2007 5:08 AM
To: Jeff Garzik
Cc: [EMAIL PROTECTED]; netdev@vger.kernel.org;
[EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [PATCH 1/2] s2io: add PCI error recovery support


This patch adds PCI error recovery support to the s2io 10-Gigabit
ethernet device driver. Third revision, blocks interrupts and the
watchdog.

Tested, seems to work well.

Signed-off-by: Linas Vepstas [EMAIL PROTECTED]
Acked-by: Ramkrishna Vepa [EMAIL PROTECTED]
Cc: Raghavendra Koushik [EMAIL PROTECTED]
Cc: Wen Xiong [EMAIL PROTECTED]



Jeff, please apply for 2.6.22

--linas


 drivers/net/s2io.c |  116
++---
 drivers/net/s2io.h |5 ++
 2 files changed, 116 insertions(+), 5 deletions(-)

Index: linux-2.6.22-rc1/drivers/net/s2io.c
===
--- linux-2.6.22-rc1.orig/drivers/net/s2io.c2007-05-14
17:05:03.0 -0500
+++ linux-2.6.22-rc1/drivers/net/s2io.c 2007-05-14 17:23:45.0
-0500
@@ -480,11 +480,18 @@ static struct pci_device_id s2io_tbl[] _
 
 MODULE_DEVICE_TABLE(pci, s2io_tbl);
 
+static struct pci_error_handlers s2io_err_handler = {
+   .error_detected = s2io_io_error_detected,
+   .slot_reset = s2io_io_slot_reset,
+   .resume = s2io_io_resume,
+};
+
 static struct pci_driver s2io_driver = {
   .name = S2IO,
   .id_table = s2io_tbl,
   .probe = s2io_init_nic,
   .remove = __devexit_p(s2io_rem_nic),
+  .err_handler = s2io_err_handler,
 };
 
 /* A simplifier macro used both by init and free shared_mem Fns(). */
@@ -2700,6 +2707,9 @@ static void s2io_netpoll(struct net_devi
u64 val64 = 0xULL;
int i;
 
+   if (pci_channel_offline(nic-pdev))
+   return;
+
disable_irq(dev-irq);
 
atomic_inc(nic-isr_cnt);
@@ -3225,6 +3235,8 @@ static void alarm_intr_handler(struct s2
int i;
if (atomic_read(nic-card_state) == CARD_DOWN)
return;
+   if (pci_channel_offline(nic-pdev))
+   return;
nic-mac_control.stats_info-sw_stat.ring_full_cnt = 0;
/* Handling the XPAK counters update */
if(nic-mac_control.stats_info-xpak_stat.xpak_timer_count 
72000) { @@ -4324,6 +4336,10 @@ static irqreturn_t s2io_isr(int irq, voi
struct mac_info *mac_control;
struct config_param *config;
 
+   /* Pretend we handled any irq's from a disconnected card */
+   if (pci_channel_offline(sp-pdev))
+   return IRQ_NONE;
+
atomic_inc(sp-isr_cnt);
mac_control = sp-mac_control;
config = sp-config;
@@ -6579,7 +6595,7 @@ static void s2io_rem_isr(struct s2io_nic
} while(cnt  5);
 }
 
-static void s2io_card_down(struct s2io_nic * sp)
+static void do_s2io_card_down(struct s2io_nic * sp, int do_io)
 {
int cnt = 0;
struct XENA_dev_config __iomem *bar0 = sp-bar0; @@ -6594,7
+6610,8 @@ static void s2io_card_down(struct s2io_n
atomic_set(sp-card_state, CARD_DOWN);
 
/* disable Tx and Rx traffic on the NIC */
-   stop_nic(sp);
+   if (do_io)
+   stop_nic(sp);
 
s2io_rem_isr(sp);
 
@@ -6602,7 +6619,7 @@ static void s2io_card_down(struct s2io_n
tasklet_kill(sp-task);
 
/* Check if the device is Quiescent and then Reset the NIC */
-   do {
+   while(do_io) {
/* As per the HW requirement we need to replenish the
 * receive buffer to avoid the ring bump. Since there is
 * no intention of processing the Rx frame at this
pointwe are @@ -6627,8 +6644,9 @@ static void s2io_card_down(struct
s2io_n
  (unsigned long long) val64);
break;
}
-   } while (1);
-   s2io_reset(sp);
+   }
+   if (do_io)
+   s2io_reset(sp);
 
spin_lock_irqsave(sp-tx_lock, flags);
/* Free all Tx buffers */
@@ -6643,6 +6661,11 @@ static void s2io_card_down(struct s2io_n
clear_bit(0, (sp-link_state));
 

[PATCH 1/6] S2IO: Fixes for MSI and MSIX

2007-02-23 Thread Sivakumar Subramani
- Added debug statements to print a debug message if the MSI/MSI-X vector (or)
  data is zero.

- This patch removes the code that will enable NAPI for the case of single 
  ring and MSI-X / MSI case. There are some issue in the enabling NAPI with
  MSI/MSI-X.  So we are turning off NAPI in the case of MSI/MSI-X. 

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
---
diff -urpN orig/drivers/net/s2io.c patch1/drivers/net/s2io.c
--- orig/drivers/net/s2io.c 2007-02-21 12:15:42.0 +0530
+++ patch1/drivers/net/s2io.c   2007-02-21 12:28:59.0 +0530
@@ -6112,7 +6112,7 @@ static int s2io_add_isr(struct s2io_nic 
}
}
if (sp-intr_type == MSI_X) {
-   int i;
+   int i, msix_tx_cnt=0,msix_rx_cnt=0;
 
for (i=1; (sp-s2io_entries[i].in_use == MSIX_FLG); i++) {
if (sp-s2io_entries[i].type == MSIX_FIFO_TYPE) {
@@ -6121,16 +6121,36 @@ static int s2io_add_isr(struct s2io_nic 
err = request_irq(sp-entries[i].vector,
  s2io_msix_fifo_handle, 0, sp-desc[i],
  sp-s2io_entries[i].arg);
-   DBG_PRINT(ERR_DBG, %s @ 0x%llx\n, sp-desc[i],
-   (unsigned long long)sp-msix_info[i].addr);
+   /* If either data or addr is zero print it */
+   if(!(sp-msix_info[i].addr 
+   sp-msix_info[i].data)) {
+   DBG_PRINT(ERR_DBG, %s @ Addr:0x%llx
+   Data:0x%lx\n,sp-desc[i],
+   (unsigned long long)
+   sp-msix_info[i].addr,
+   (unsigned long)
+   ntohl(sp-msix_info[i].data));
+   } else {
+   msix_tx_cnt++;
+   }
} else {
sprintf(sp-desc[i], %s:MSI-X-%d-RX,
dev-name, i);
err = request_irq(sp-entries[i].vector,
  s2io_msix_ring_handle, 0, sp-desc[i],
  sp-s2io_entries[i].arg);
-   DBG_PRINT(ERR_DBG, %s @ 0x%llx\n, sp-desc[i],
-   (unsigned long long)sp-msix_info[i].addr);
+   /* If either data or addr is zero print it */
+   if(!(sp-msix_info[i].addr 
+   sp-msix_info[i].data)) {
+   DBG_PRINT(ERR_DBG, %s @ Addr:0x%llx
+   Data:0x%lx\n,sp-desc[i],
+   (unsigned long long)
+   sp-msix_info[i].addr,
+   (unsigned long)
+   ntohl(sp-msix_info[i].data));
+   } else {
+   msix_rx_cnt++;
+   }
}
if (err) {
DBG_PRINT(ERR_DBG,%s:MSI-X-%d registration 
@@ -6140,6 +6160,8 @@ static int s2io_add_isr(struct s2io_nic 
}
sp-s2io_entries[i].in_use = MSIX_REGISTERED_SUCCESS;
}
+   printk(MSI-X-TX %d entries enabled\n,msix_tx_cnt);
+   printk(MSI-X-RX %d entries enabled\n,msix_rx_cnt);
}
if (sp-intr_type == INTA) {
err = request_irq((int) sp-pdev-irq, s2io_isr, IRQF_SHARED,
@@ -6704,8 +6726,7 @@ static int s2io_verify_parm(struct pci_d
Defaulting to INTA\n);
*dev_intr_type = INTA;
}
-   if ( (rx_ring_num  1)  (*dev_intr_type != INTA) )
-   napi = 0;
+
if (rx_ring_mode  3) {
DBG_PRINT(ERR_DBG, s2io: Requested ring mode not supported\n);
DBG_PRINT(ERR_DBG, s2io: Defaulting to 3-buffer mode\n);

-
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] S2IO: Optimized the delay to wait for command completion

2007-02-23 Thread Sivakumar Subramani
- Optimized delay to wait for command completion so as to reduce the
  initialization wait time.
- Disable differentiated services steering. By default RMAC is configured to
  steer traffic with certain DS codes to other queues. Driver must initialize
  the DS memory to 0 to make sure that DS steering will not be used by default.

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
---
diff -urpN patch1/drivers/net/s2io.c patch2/drivers/net/s2io.c
--- patch1/drivers/net/s2io.c   2007-02-21 12:28:59.0 +0530
+++ patch2/drivers/net/s2io.c   2007-02-21 15:21:14.0 +0530
@@ -1372,6 +1372,16 @@ static int init_nic(struct s2io_nic *nic
}
}
 
+   /* Disable differentiated services steering logic */
+   for (i = 0; i  64; i++) {
+   if (rts_ds_steer(nic, i, 0) == FAILURE) {
+   DBG_PRINT(ERR_DBG, %s: failed rts ds steering,
+   dev-name);
+   DBG_PRINT(ERR_DBG, set on codepoint %d\n, i);
+   return FAILURE;
+   }
+   }
+
/* Program statistics memory */
writeq(mac_control-stats_mem_phy, bar0-stat_addr);
 
@@ -3195,26 +3205,37 @@ static void alarm_intr_handler(struct s2
  *   SUCCESS on success and FAILURE on failure.
  */
 
-static int wait_for_cmd_complete(void __iomem *addr, u64 busy_bit)
+static int wait_for_cmd_complete(void __iomem *addr, u64 busy_bit,
+   int bit_state)
 {
-   int ret = FAILURE, cnt = 0;
+   int ret = FAILURE, cnt = 0, delay = 1;
u64 val64;
 
-   while (TRUE) {
+   if ((bit_state != S2IO_BIT_RESET)  (bit_state != S2IO_BIT_SET))
+   return FAILURE;
+
+   do {
val64 = readq(addr);
-   if (!(val64  busy_bit)) {
-   ret = SUCCESS;
-   break;
+   if (bit_state == S2IO_BIT_RESET) {
+   if (!(val64  busy_bit)) {
+   ret = SUCCESS;
+   break;
+   }
+   } else {
+   if (!(val64  busy_bit)) {
+   ret = SUCCESS;
+   break;
+   }
}
 
if(in_interrupt())
-   mdelay(50);
+   mdelay(delay);
else
-   msleep(50);
+   msleep(delay);
 
-   if (cnt++  10)
-   break;
-   }
+   if (++cnt = 10)
+   delay = 50;
+   } while (cnt  20);
return ret;
 }
 /*
@@ -4296,7 +4317,8 @@ static void s2io_set_multicast(struct ne
writeq(val64, bar0-rmac_addr_cmd_mem);
/* Wait till command completes */
wait_for_cmd_complete(bar0-rmac_addr_cmd_mem,
- RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING);
+   RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING,
+   S2IO_BIT_RESET);
 
sp-m_cast_flg = 1;
sp-all_multi_pos = MAC_MC_ALL_MC_ADDR_OFFSET;
@@ -4312,7 +4334,8 @@ static void s2io_set_multicast(struct ne
writeq(val64, bar0-rmac_addr_cmd_mem);
/* Wait till command completes */
wait_for_cmd_complete(bar0-rmac_addr_cmd_mem,
- RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING);
+   RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING,
+   S2IO_BIT_RESET);
 
sp-m_cast_flg = 0;
sp-all_multi_pos = 0;
@@ -4378,7 +4401,8 @@ static void s2io_set_multicast(struct ne
 
/* Wait for command completes */
if (wait_for_cmd_complete(bar0-rmac_addr_cmd_mem,
- RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING)) {
+   RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING,
+   S2IO_BIT_RESET)) {
DBG_PRINT(ERR_DBG, %s: Adding ,
  dev-name);
DBG_PRINT(ERR_DBG, Multicasts failed\n);
@@ -4409,7 +4433,8 @@ static void s2io_set_multicast(struct ne
 
/* Wait for command completes */
if (wait_for_cmd_complete(bar0-rmac_addr_cmd_mem,
- RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING)) {
+   RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING,
+   S2IO_BIT_RESET)) {
DBG_PRINT(ERR_DBG, %s: Adding ,
  dev-name);
DBG_PRINT(ERR_DBG, Multicasts failed\n

[PATCH 3/6] S2IO: Added a loadable parameter to enable or disable vlan stripping in frame.

2007-02-23 Thread Sivakumar Subramani
- Added code to not to strip vlan tag when driver is in promiscuous mode
- Added module loadable parameter 'vlan_tag_strip through which user can
  enable or disable vlan stripping irrespective of mode
  ( promiscuous or non-promiscuous ). 

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
---
diff -urpN patch2/drivers/net/s2io.c patch3/drivers/net/s2io.c
--- patch2/drivers/net/s2io.c   2007-02-21 15:21:14.0 +0530
+++ patch3/drivers/net/s2io.c   2007-02-24 11:42:48.0 +0530
@@ -42,6 +42,14 @@
  * Possible values '1' for enable '0' for disable. Default is '0'
  * lro_max_pkts: This parameter defines maximum number of packets can be
  * aggregated as a single large packet
+ * napi: This parameter used to enable/disable NAPI (polling Rx)
+ * Possible values '1' for enable and '0' for disable. Default is '1'
+ * ufo: This parameter used to enable/disable UDP Fragmentation Offload(UFO)
+ *  Possible values '1' for enable and '0' for disable. Default is '0'
+ * vlan_tag_strip: This can be used to enable or disable vlan stripping.
+ * Possible values '1' for enable , '0' for disable.
+ * Default is '2' - which means disable in promisc mode
+ * and enable in non-promiscuous mode.
  /
 
 #include linux/module.h
@@ -293,6 +301,9 @@ static void s2io_vlan_rx_register(struct
spin_unlock_irqrestore(nic-tx_lock, flags);
 }
 
+/* A flag indicating whether 'RX_PA_CFG_STRIP_VLAN_TAG' bit is set or not */
+int vlan_strip_flag;
+
 /* Unregister the vlan */
 static void s2io_vlan_rx_kill_vid(struct net_device *dev, unsigned long vid)
 {
@@ -404,6 +415,7 @@ S2IO_PARM_INT(indicate_max_pkts, 0);
 
 S2IO_PARM_INT(napi, 1);
 S2IO_PARM_INT(ufo, 0);
+S2IO_PARM_INT(vlan_tag_strip, NO_STRIP_IN_PROMISC);
 
 static unsigned int tx_fifo_len[MAX_TX_FIFOS] =
 {DEFAULT_FIFO_0_LEN, [1 ...(MAX_TX_FIFOS - 1)] = DEFAULT_FIFO_1_7_LEN};
@@ -1371,7 +1383,7 @@ static int init_nic(struct s2io_nic *nic
bar0-rts_frm_len_n[i]);
}
}
-
+   
/* Disable differentiated services steering logic */
for (i = 0; i  64; i++) {
if (rts_ds_steer(nic, i, 0) == FAILURE) {
@@ -1953,6 +1965,13 @@ static int start_nic(struct s2io_nic *ni
writeq(val64, bar0-rx_pa_cfg);
}
 
+   if (vlan_tag_strip == 0) {
+   val64 = readq(bar0-rx_pa_cfg);
+   val64 = ~RX_PA_CFG_STRIP_VLAN_TAG;
+   writeq(val64, bar0-rx_pa_cfg);
+   vlan_strip_flag = 0;
+   }
+
/*
 * Enabling MC-RLDRAM. After enabling the device, we timeout
 * for around 100ms, which is approximately the time required
@@ -4352,6 +4371,13 @@ static void s2io_set_multicast(struct ne
writeq(RMAC_CFG_KEY(0x4C0D), bar0-rmac_cfg_key);
writel((u32) (val64  32), (add + 4));
 
+   if (vlan_tag_strip != 1) {
+   val64 = readq(bar0-rx_pa_cfg);
+   val64 = ~RX_PA_CFG_STRIP_VLAN_TAG;
+   writeq(val64, bar0-rx_pa_cfg);
+   vlan_strip_flag = 0;
+   }
+
val64 = readq(bar0-mac_cfg);
sp-promisc_flg = 1;
DBG_PRINT(INFO_DBG, %s: entered promiscuous mode\n,
@@ -4367,6 +4393,13 @@ static void s2io_set_multicast(struct ne
writeq(RMAC_CFG_KEY(0x4C0D), bar0-rmac_cfg_key);
writel((u32) (val64  32), (add + 4));
 
+   if (vlan_tag_strip != 0) {
+   val64 = readq(bar0-rx_pa_cfg);
+   val64 |= RX_PA_CFG_STRIP_VLAN_TAG;
+   writeq(val64, bar0-rx_pa_cfg);
+   vlan_strip_flag = 1;
+   }
+
val64 = readq(bar0-mac_cfg);
sp-promisc_flg = 0;
DBG_PRINT(INFO_DBG, %s: left promiscuous mode\n,
@@ -6614,7 +6647,8 @@ static int rx_osm_handler(struct ring_in
 
if (!sp-lro) {
skb-protocol = eth_type_trans(skb, dev);
-   if (sp-vlgrp  RXD_GET_VLAN_TAG(rxdp-Control_2)) {
+   if ((sp-vlgrp  RXD_GET_VLAN_TAG(rxdp-Control_2) 
+   vlan_strip_flag)) {
/* Queueing the vlan frame to the upper layer */
if (napi)
vlan_hwaccel_receive_skb(skb, sp-vlgrp,
diff -urpN patch2/drivers/net/s2io.h patch3/drivers/net/s2io.h
--- patch2/drivers/net/s2io.h   2007-02-20 14:47:46.0 +0530
+++ patch3/drivers/net/s2io.h   2007-02-21 14:54:19.0 +0530
@@ -297,6 +297,9 @@ struct stat_block {
struct xpakStat xpak_stat;
 };
 
+/* Default value for 'vlan_strip_tag' configuration parameter */
+#define NO_STRIP_IN_PROMISC 2
+
 /*
  * Structures representing different init time configuration
  * parameters of the NIC

[PATCH 4/6] S2IO: Making LED off during LINK_DOWN notification.

2007-02-23 Thread Sivakumar Subramani
- Turning off LED for LINK_DOWN notification
- Return from rxd_owner_bit_reset function if call to set_rxd_buffer_pointer
  fails with ENOMEM

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
---
diff -urpN patch3/drivers/net/s2io.c patch4/drivers/net/s2io.c
--- patch3/drivers/net/s2io.c   2007-02-24 11:42:48.0 +0530
+++ patch4/drivers/net/s2io.c   2007-02-21 15:22:13.0 +0530
@@ -4127,6 +4127,11 @@ static void s2io_txpic_intr_handle(struc
val64 = ~GPIO_INT_MASK_LINK_UP;
val64 |= GPIO_INT_MASK_LINK_DOWN;
writeq(val64, bar0-gpio_int_mask);
+
+   /* turn off LED */
+   val64 = readq(bar0-adapter_control);
+   val64 = val64 (~ADAPTER_LED_ON);
+   writeq(val64, bar0-adapter_control);
}
}
val64 = readq(bar0-gpio_int_mask);
@@ -6124,10 +6129,13 @@ static  int rxd_owner_bit_reset(struct s
rx_blocks[j].rxds[k].virt_addr;
if(sp-rxd_mode = RXD_MODE_3A)
ba = mac_control-rings[i].ba[j][k];
-   set_rxd_buffer_pointer(sp, rxdp, ba,
+   if (set_rxd_buffer_pointer(sp, rxdp, ba,
   skb,(u64 *)temp0_64,
   (u64 *)temp1_64,
-  (u64 *)temp2_64, size);
+  (u64 *)temp2_64,
+   size) == ENOMEM) {
+   return 0;
+   }
 
set_rxd_buffer_size(sp, rxdp, size);
wmb();

-
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 5/6] S2IO: Avoid printing the Enhanced statistics for Xframe I card.

2007-02-23 Thread Sivakumar Subramani
- Enhanced Statistics are supported only for Xframe II (Herculas) card. Add 
  condition check such Enhanced statistics will included only in the case of
  Xframe II card.

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
---
diff -urpN patch4/drivers/net/s2io.c patch5/drivers/net/s2io.c
--- patch4/drivers/net/s2io.c   2007-02-21 15:22:13.0 +0530
+++ patch5/drivers/net/s2io.c   2007-02-21 15:23:00.0 +0530
@@ -139,7 +139,7 @@ static char s2io_gstrings[][ETH_GSTRING_
BIST Test\t(offline)
 };
 
-static char ethtool_stats_keys[][ETH_GSTRING_LEN] = {
+static char ethtool_xena_stats_keys[][ETH_GSTRING_LEN] = {
{tmac_frms},
{tmac_data_octets},
{tmac_drop_frms},
@@ -233,7 +233,10 @@ static char ethtool_stats_keys[][ETH_GST
{rxd_rd_cnt},
{rxd_wr_cnt},
{txf_rd_cnt},
-   {rxf_wr_cnt},
+   {rxf_wr_cnt}
+};
+
+static char ethtool_enhanced_stats_keys[][ETH_GSTRING_LEN] = {
{rmac_ttl_1519_4095_frms},
{rmac_ttl_4096_8191_frms},
{rmac_ttl_8192_max_frms},
@@ -249,7 +252,10 @@ static char ethtool_stats_keys[][ETH_GST
{rmac_red_discard},
{rmac_rts_discard},
{rmac_ingm_full_discard},
-   {link_fault_cnt},
+   {link_fault_cnt}
+};
+
+static char ethtool_driver_stats_keys[][ETH_GSTRING_LEN] = {
{\n DRIVER STATISTICS},
{single_bit_ecc_errs},
{double_bit_ecc_errs},
@@ -277,8 +283,16 @@ static char ethtool_stats_keys[][ETH_GST
(lro_avg_aggr_pkts),
 };
 
-#define S2IO_STAT_LEN sizeof(ethtool_stats_keys)/ ETH_GSTRING_LEN
-#define S2IO_STAT_STRINGS_LEN S2IO_STAT_LEN * ETH_GSTRING_LEN
+#define S2IO_XENA_STAT_LEN sizeof(ethtool_xena_stats_keys)/ ETH_GSTRING_LEN
+#define S2IO_ENHANCED_STAT_LEN sizeof(ethtool_enhanced_stats_keys)/ \
+   ETH_GSTRING_LEN
+#define S2IO_DRIVER_STAT_LEN sizeof(ethtool_driver_stats_keys)/ ETH_GSTRING_LEN
+
+#define XFRAME_I_STAT_LEN (S2IO_XENA_STAT_LEN + S2IO_DRIVER_STAT_LEN )
+#define XFRAME_II_STAT_LEN (XFRAME_I_STAT_LEN + S2IO_ENHANCED_STAT_LEN )
+
+#define XFRAME_I_STAT_STRINGS_LEN ( XFRAME_I_STAT_LEN * ETH_GSTRING_LEN )
+#define XFRAME_II_STAT_STRINGS_LEN ( XFRAME_II_STAT_LEN * ETH_GSTRING_LEN )
 
 #define S2IO_TEST_LEN  sizeof(s2io_gstrings) / ETH_GSTRING_LEN
 #define S2IO_STRINGS_LEN   S2IO_TEST_LEN * ETH_GSTRING_LEN
@@ -4609,7 +4623,11 @@ static void s2io_ethtool_gdrvinfo(struct
info-regdump_len = XENA_REG_SPACE;
info-eedump_len = XENA_EEPROM_SPACE;
info-testinfo_len = S2IO_TEST_LEN;
-   info-n_stats = S2IO_STAT_LEN;
+
+   if (sp-device_type == XFRAME_I_DEVICE)
+   info-n_stats = XFRAME_I_STAT_LEN;
+   else
+   info-n_stats = XFRAME_II_STAT_LEN;
 }
 
 /**
@@ -5631,22 +5649,30 @@ static void s2io_get_ethtool_stats(struc
tmp_stats[i++] = le32_to_cpu(stat_info-rxd_wr_cnt);
tmp_stats[i++] = le32_to_cpu(stat_info-txf_rd_cnt);
tmp_stats[i++] = le32_to_cpu(stat_info-rxf_wr_cnt);
-   tmp_stats[i++] = le64_to_cpu(stat_info-rmac_ttl_1519_4095_frms);
-tmp_stats[i++] = le64_to_cpu(stat_info-rmac_ttl_4096_8191_frms);
-tmp_stats[i++] = le64_to_cpu(stat_info-rmac_ttl_8192_max_frms);
-tmp_stats[i++] = le64_to_cpu(stat_info-rmac_ttl_gt_max_frms);
-tmp_stats[i++] = le64_to_cpu(stat_info-rmac_osized_alt_frms);
-tmp_stats[i++] = le64_to_cpu(stat_info-rmac_jabber_alt_frms);
-tmp_stats[i++] = le64_to_cpu(stat_info-rmac_gt_max_alt_frms);
-tmp_stats[i++] = le64_to_cpu(stat_info-rmac_vlan_frms);
-tmp_stats[i++] = le32_to_cpu(stat_info-rmac_len_discard);
-tmp_stats[i++] = le32_to_cpu(stat_info-rmac_fcs_discard);
-tmp_stats[i++] = le32_to_cpu(stat_info-rmac_pf_discard);
-tmp_stats[i++] = le32_to_cpu(stat_info-rmac_da_discard);
-tmp_stats[i++] = le32_to_cpu(stat_info-rmac_red_discard);
-tmp_stats[i++] = le32_to_cpu(stat_info-rmac_rts_discard);
-tmp_stats[i++] = le32_to_cpu(stat_info-rmac_ingm_full_discard);
-tmp_stats[i++] = le32_to_cpu(stat_info-link_fault_cnt);
+
+   /* Enhanced statistics exist only for Hercules */
+   if(sp-device_type == XFRAME_II_DEVICE) {
+   tmp_stats[i++] =
+   le64_to_cpu(stat_info-rmac_ttl_1519_4095_frms);
+   tmp_stats[i++] =
+   le64_to_cpu(stat_info-rmac_ttl_4096_8191_frms);
+   tmp_stats[i++] =
+   le64_to_cpu(stat_info-rmac_ttl_8192_max_frms);
+   tmp_stats[i++] = le64_to_cpu(stat_info-rmac_ttl_gt_max_frms);
+   tmp_stats[i++] = le64_to_cpu(stat_info-rmac_osized_alt_frms);
+   tmp_stats[i++] = le64_to_cpu(stat_info-rmac_jabber_alt_frms);
+   tmp_stats[i++] = le64_to_cpu(stat_info-rmac_gt_max_alt_frms);
+   tmp_stats[i++] = le64_to_cpu(stat_info-rmac_vlan_frms);
+   tmp_stats[i

[PATCH 6/6] S2IO: Restoring the mac address in s2io_reset

2007-02-23 Thread Sivakumar Subramani
- Restore in s2io_reset, the mac address assigned during s2io_open.
  Earlier, it was getting overwritten to the factory default (read from the
  eeprom) and subsequently dropping received frames.

- Fixed the typo in calling rtnl_unlock in s2io_set_link function.

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
---
diff -urpN patch5/drivers/net/s2io.c patch6/drivers/net/s2io.c
--- patch5/drivers/net/s2io.c   2007-02-21 15:23:00.0 +0530
+++ patch6/drivers/net/s2io.c   2007-02-21 17:02:48.0 +0530
@@ -84,7 +84,7 @@
 #include s2io.h
 #include s2io-regs.h
 
-#define DRV_VERSION 2.0.16.1
+#define DRV_VERSION 2.0.17.1
 
 /* S2io Driver name  version. */
 static char s2io_driver_name[] = Neterion;
@@ -3394,6 +3394,9 @@ new_way:
writeq(val64, bar0-pcc_err_reg);
}
 
+   /* restore the previously assigned mac address */
+   s2io_set_mac_addr(sp-dev, (u8 *)sp-def_mac_addr[0].mac_addr);
+
sp-device_enabled_once = FALSE;
 }
 
@@ -4512,6 +4515,7 @@ static int s2io_set_mac_addr(struct net_
struct XENA_dev_config __iomem *bar0 = sp-bar0;
register u64 val64, mac_addr = 0;
int i;
+   u64 old_mac_addr = 0;
 
/*
 * Set the new MAC address as the new unicast filter and reflect this
@@ -4521,6 +4525,22 @@ static int s2io_set_mac_addr(struct net_
for (i = 0; i  ETH_ALEN; i++) {
mac_addr = 8;
mac_addr |= addr[i];
+   old_mac_addr = 8;
+   old_mac_addr |= sp-def_mac_addr[0].mac_addr[i];
+   }
+
+   if(0 == mac_addr)
+   return SUCCESS;
+
+   /* Update the internal structure with this new mac address */
+   if(mac_addr != old_mac_addr) {
+   memset(sp-def_mac_addr[0].mac_addr, 0, sizeof(ETH_ALEN));
+   sp-def_mac_addr[0].mac_addr[5] = (u8) (mac_addr);
+   sp-def_mac_addr[0].mac_addr[4] = (u8) (mac_addr  8);
+   sp-def_mac_addr[0].mac_addr[3] = (u8) (mac_addr  16);
+   sp-def_mac_addr[0].mac_addr[2] = (u8) (mac_addr  24);
+   sp-def_mac_addr[0].mac_addr[1] = (u8) (mac_addr  32);
+   sp-def_mac_addr[0].mac_addr[0] = (u8) (mac_addr  40);
}
 
writeq(RMAC_ADDR_DATA0_MEM_ADDR(mac_addr),
@@ -6022,7 +6042,7 @@ static void s2io_set_link(struct work_st
clear_bit(0, (nic-link_state));
 
 out_unlock:
-   rtnl_lock();
+   rtnl_unlock();
 }
 
 static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
@@ -7182,8 +7202,6 @@ s2io_init_nic(struct pci_dev *pdev, cons
mac_down = (u32) tmp64;
mac_up = (u32) (tmp64  32);
 
-   memset(sp-def_mac_addr[0].mac_addr, 0, sizeof(ETH_ALEN));
-
sp-def_mac_addr[0].mac_addr[3] = (u8) (mac_up);
sp-def_mac_addr[0].mac_addr[2] = (u8) (mac_up  8);
sp-def_mac_addr[0].mac_addr[1] = (u8) (mac_up  16);

-
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.20 1/5] s2io: Making LRO and UFO as module loadable parameter.

2007-01-31 Thread Sivakumar Subramani
This patch adds two load parameters napi and ufo. Previously NAPI was
compilation option with these changes wan enable disable NAPI using load
parameter. Also we are introducing ufo load parameter to enable/disable
ufo feature

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
---
diff -urpN orig/drivers/net/s2io.c patch1/drivers/net/s2io.c
--- orig/drivers/net/s2io.c 2007-01-31 23:29:43.0 +0530
+++ patch1/drivers/net/s2io.c   2007-01-31 21:02:31.0 +0530
@@ -401,9 +401,10 @@ S2IO_PARM_INT(lro, 0);
  * aggregation happens until we hit max IP pkt size(64K)
  */
 S2IO_PARM_INT(lro_max_pkts, 0x);
-#ifndef CONFIG_S2IO_NAPI
 S2IO_PARM_INT(indicate_max_pkts, 0);
-#endif
+
+S2IO_PARM_INT(napi, 1);
+S2IO_PARM_INT(ufo, 0);
 
 static unsigned int tx_fifo_len[MAX_TX_FIFOS] =
 {DEFAULT_FIFO_0_LEN, [1 ...(MAX_TX_FIFOS - 1)] = DEFAULT_FIFO_1_7_LEN};
@@ -2274,9 +2275,7 @@ static int fill_rx_buffers(struct s2io_n
struct config_param *config;
u64 tmp;
buffAdd_t *ba;
-#ifndef CONFIG_S2IO_NAPI
unsigned long flags;
-#endif
RxD_t *first_rxdp = NULL;
 
mac_control = nic-mac_control;
@@ -2320,12 +2319,15 @@ static int fill_rx_buffers(struct s2io_n
DBG_PRINT(INTR_DBG, %s: Next block at: %p\n,
  dev-name, rxdp);
}
-#ifndef CONFIG_S2IO_NAPI
-   spin_lock_irqsave(nic-put_lock, flags);
-   mac_control-rings[ring_no].put_pos =
-   (block_no * (rxd_count[nic-rxd_mode] + 1)) + off;
-   spin_unlock_irqrestore(nic-put_lock, flags);
-#endif
+   if(!napi) {
+   spin_lock_irqsave(nic-put_lock, flags);
+   mac_control-rings[ring_no].put_pos =
+   (block_no * (rxd_count[nic-rxd_mode] + 1)) + off;
+   spin_unlock_irqrestore(nic-put_lock, flags);
+   } else {
+   mac_control-rings[ring_no].put_pos =
+   (block_no * (rxd_count[nic-rxd_mode] + 1)) + off;
+   }
if ((rxdp-Control_1  RXD_OWN_XENA) 
((nic-rxd_mode = RXD_MODE_3A) 
(rxdp-Control_2  BIT(0 {
@@ -2568,7 +2570,6 @@ static void free_rx_buffers(struct s2io_
  * 0 on success and 1 if there are No Rx packets to be processed.
  */
 
-#if defined(CONFIG_S2IO_NAPI)
 static int s2io_poll(struct net_device *dev, int *budget)
 {
nic_t *nic = dev-priv;
@@ -2633,7 +2634,6 @@ no_rx:
atomic_dec(nic-isr_cnt);
return 1;
 }
-#endif
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
 /**
@@ -2707,9 +2707,7 @@ static void rx_intr_handler(ring_info_t 
rx_curr_get_info_t get_info, put_info;
RxD_t *rxdp;
struct sk_buff *skb;
-#ifndef CONFIG_S2IO_NAPI
int pkt_cnt = 0;
-#endif
int i;
 
spin_lock(nic-rx_lock);
@@ -2725,16 +2723,18 @@ static void rx_intr_handler(ring_info_t 
put_info = ring_data-rx_curr_put_info;
put_block = put_info.block_index;
rxdp = ring_data-rx_blocks[get_block].rxds[get_info.offset].virt_addr;
-#ifndef CONFIG_S2IO_NAPI
-   spin_lock(nic-put_lock);
-   put_offset = ring_data-put_pos;
-   spin_unlock(nic-put_lock);
-#else
-   put_offset = (put_block * (rxd_count[nic-rxd_mode] + 1)) +
-   put_info.offset;
-#endif
+   if (!napi) {
+   spin_lock(nic-put_lock);
+   put_offset = ring_data-put_pos;
+   spin_unlock(nic-put_lock);
+   } else
+   put_offset = ring_data-put_pos;
+
while (RXD_IS_UP2DT(rxdp)) {
-   /* If your are next to put index then it's FIFO full condition 
*/
+   /*
+* If your are next to put index then it's
+* FIFO full condition
+*/
if ((get_block == put_block) 
(get_info.offset + 1) == put_info.offset) {
DBG_PRINT(INTR_DBG, %s: Ring Full\n,dev-name);
@@ -2792,15 +2792,12 @@ static void rx_intr_handler(ring_info_t 
rxdp = ring_data-rx_blocks[get_block].block_virt_addr;
}
 
-#ifdef CONFIG_S2IO_NAPI
nic-pkts_to_process -= 1;
-   if (!nic-pkts_to_process)
+   if ((napi)  (!nic-pkts_to_process))
break;
-#else
pkt_cnt++;
if ((indicate_max_pkts)  (pkt_cnt  indicate_max_pkts))
break;
-#endif
}
if (nic-lro) {
/* Clear all LRO sessions before exiting */
@@ -4193,26 +4190,26 @@ static irqreturn_t s2io_isr(int irq, voi
org_mask = readq(bar0-general_int_mask);
writeq(val64, bar0-general_int_mask);
 
-#ifdef CONFIG_S2IO_NAPI
-   if (reason  GEN_INTR_RXTRAFFIC) {
-   if (netif_rx_schedule_prep(dev)) {
-   writeq(val64, bar0

[PATCH 2.6.20 2/5] S2IO: Fixes for reset and link handling.

2007-01-31 Thread Sivakumar Subramani
1. Fix for reset and link handling.
2. Allow for promiscuos mode and multicast state be maintained through
   ifconfig up and down.
3. Support to print adapter serial number.

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
---
diff -urpN patch1/drivers/net/s2io.c patch2/drivers/net/s2io.c
--- patch1/drivers/net/s2io.c   2007-01-31 21:02:31.0 +0530
+++ patch2/drivers/net/s2io.c   2007-01-31 22:49:54.0 +0530
@@ -1415,7 +1415,7 @@ static int init_nic(struct s2io_nic *nic
 
val64 = TTI_DATA2_MEM_TX_UFC_A(0x10) |
TTI_DATA2_MEM_TX_UFC_B(0x20) |
-   TTI_DATA2_MEM_TX_UFC_C(0x70) | TTI_DATA2_MEM_TX_UFC_D(0x80);
+   TTI_DATA2_MEM_TX_UFC_C(0x40) | TTI_DATA2_MEM_TX_UFC_D(0x80);
writeq(val64, bar0-tti_data2_mem);
 
val64 = TTI_CMD_MEM_WE | TTI_CMD_MEM_STROBE_NEW_CMD;
@@ -1611,7 +1611,8 @@ static int init_nic(struct s2io_nic *nic
 * that does not start on an ADB to reduce disconnects.
 */
if (nic-device_type == XFRAME_II_DEVICE) {
-   val64 = EXT_REQ_EN | MISC_LINK_STABILITY_PRD(3);
+   val64 = FAULT_BEHAVIOUR | EXT_REQ_EN |
+   MISC_LINK_STABILITY_PRD(3);
writeq(val64, bar0-misc_control);
val64 = readq(bar0-pic_control2);
val64 = ~(BIT(13)|BIT(14)|BIT(15));
@@ -1878,41 +1879,36 @@ static void en_dis_able_nic_intrs(struct
}
 }
 
-static int check_prc_pcc_state(u64 val64, int flag, int rev_id, int herc)
+/**
+ *  verify_pcc_quiescent- Checks for PCC quiescent state
+ *  Return: 1 If PCC is quiescence
+ *  0 If PCC is not quiescence
+ */
+static int verify_pcc_quiescent(nic_t *sp, int flag)
 {
-   int ret = 0;
+   int ret = 0, herc;
+   XENA_dev_config_t __iomem *bar0 = sp-bar0;
+   u64 val64 = readq(bar0-adapter_status);
+   
+   herc = (sp-device_type == XFRAME_II_DEVICE);
 
if (flag == FALSE) {
-   if ((!herc  (rev_id = 4)) || herc) {
-   if (!(val64  ADAPTER_STATUS_RMAC_PCC_IDLE) 
-   ((val64  ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
-ADAPTER_STATUS_RC_PRC_QUIESCENT)) {
+   if ((!herc  (get_xena_rev_id(sp-pdev) = 4)) || herc) {
+   if (!(val64  ADAPTER_STATUS_RMAC_PCC_IDLE))
ret = 1;
-   }
-   }else {
-   if (!(val64  ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE) 
-   ((val64  ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
-ADAPTER_STATUS_RC_PRC_QUIESCENT)) {
+   } else {
+   if (!(val64  ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE))
ret = 1;
-   }
}
} else {
-   if ((!herc  (rev_id = 4)) || herc) {
+   if ((!herc  (get_xena_rev_id(sp-pdev) = 4)) || herc) {
if (((val64  ADAPTER_STATUS_RMAC_PCC_IDLE) ==
-ADAPTER_STATUS_RMAC_PCC_IDLE) 
-   (!(val64  ADAPTER_STATUS_RC_PRC_QUIESCENT) ||
-((val64  ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
- ADAPTER_STATUS_RC_PRC_QUIESCENT))) {
+ADAPTER_STATUS_RMAC_PCC_IDLE))
ret = 1;
-   }
} else {
if (((val64  ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE) ==
-ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE) 
-   (!(val64  ADAPTER_STATUS_RC_PRC_QUIESCENT) ||
-((val64  ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
- ADAPTER_STATUS_RC_PRC_QUIESCENT))) {
+ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE))
ret = 1;
-   }
}
}
 
@@ -1920,9 +1916,6 @@ static int check_prc_pcc_state(u64 val64
 }
 /**
  *  verify_xena_quiescence - Checks whether the H/W is ready
- *  @val64 :  Value read from adapter status register.
- *  @flag : indicates if the adapter enable bit was ever written once
- *  before.
  *  Description: Returns whether the H/W is ready to go or not. Depending
  *  on whether adapter enable bit was written or not the comparison
  *  differs and the calling function passes the input argument flag to
@@ -1931,24 +1924,63 @@ static int check_prc_pcc_state(u64 val64
  *  0 If Xena is not quiescence
  */
 
-static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag)
+static int verify_xena_quiescence(nic_t *sp)
 {
-   int ret = 0, herc;
-   u64 tmp64 = ~((u64) val64);
-   int rev_id = get_xena_rev_id(sp-pdev);
+   int  mode;
+   XENA_dev_config_t __iomem *bar0 = sp-bar0;
+   u64 val64 = readq(bar0-adapter_status);
+   mode = s2io_verify_pci_mode(sp);
 
-   herc = (sp

[PATCH 2.6.20 3/5] s2io: Fixes in updating skb-truesize and code cleanup.

2007-01-31 Thread Sivakumar Subramani
1. Fix for updating skb-truesize properly.
2. Disable NAPI only if more than one ring configured in case of MSI/MSI-X
   interrupts. Previously we were disabling NAPI irrespective of number of
   rings when MSI/MSI-X interrupts were used.
3. Code cleanup.

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
---
diff -urpN patch2/drivers/net/s2io.c patch3/drivers/net/s2io.c
--- patch2/drivers/net/s2io.c   2007-01-31 22:49:54.0 +0530
+++ patch3/drivers/net/s2io.c   2007-01-31 22:50:24.0 +0530
@@ -459,7 +459,7 @@ static int init_shared_mem(struct s2io_n
void *tmp_v_addr, *tmp_v_addr_next;
dma_addr_t tmp_p_addr, tmp_p_addr_next;
RxD_block_t *pre_rxd_blk = NULL;
-   int i, j, blk_cnt, rx_sz, tx_sz;
+   int i, j, blk_cnt;
int lst_size, lst_per_page;
struct net_device *dev = nic-dev;
unsigned long tmp;
@@ -484,7 +484,6 @@ static int init_shared_mem(struct s2io_n
}
 
lst_size = (sizeof(TxD_t) * config-max_txds);
-   tx_sz = lst_size * size;
lst_per_page = PAGE_SIZE / lst_size;
 
for (i = 0; i  config-tx_fifo_num; i++) {
@@ -583,7 +582,6 @@ static int init_shared_mem(struct s2io_n
size = (size * (sizeof(RxD1_t)));
else
size = (size * (sizeof(RxD3_t)));
-   rx_sz = size;
 
for (i = 0; i  config-rx_ring_num; i++) {
mac_control-rings[i].rx_curr_get_info.block_index = 0;
@@ -624,6 +622,8 @@ static int init_shared_mem(struct s2io_n
rx_blocks-rxds = kmalloc(sizeof(rxd_info_t)*
  rxd_count[nic-rxd_mode],
  GFP_KERNEL);
+   if (!rx_blocks-rxds)
+   return -ENOMEM;
for (l=0; lrxd_count[nic-rxd_mode];l++) {
rx_blocks-rxds[l].virt_addr =
rx_blocks-block_virt_addr +
@@ -2259,6 +2259,7 @@ static int fill_rxd_3buf(nic_t *nic, RxD
return -ENOMEM ;
}
frag_list = skb_shinfo(skb)-frag_list;
+   skb-truesize += frag_list-truesize;
frag_list-next = NULL;
tmp = (void *)ALIGN((long)frag_list-data, ALIGN_SIZE + 1);
frag_list-data = tmp;
@@ -3185,6 +3186,8 @@ static void alarm_intr_handler(struct s2
register u64 val64 = 0, err_reg = 0;
u64 cnt;
int i;
+   if (atomic_read(nic-card_state) == CARD_DOWN)
+   return;
nic-mac_control.stats_info-sw_stat.ring_full_cnt = 0;
/* Handling the XPAK counters update */
if(nic-mac_control.stats_info-xpak_stat.xpak_timer_count  72000) {
@@ -6576,7 +6579,6 @@ static int rx_osm_handler(ring_info_t *r
skb_put(skb, buf1_len);
skb-len += buf2_len;
skb-data_len += buf2_len;
-   skb-truesize += buf2_len;
skb_put(skb_shinfo(skb)-frag_list, buf2_len);
sp-stats.rx_bytes += buf1_len;
 
@@ -6797,6 +6799,8 @@ static int s2io_verify_parm(struct pci_d
Defaulting to INTA\n);
*dev_intr_type = INTA;
}
+   if ( (rx_ring_num  1)  (*dev_intr_type != INTA) )
+   napi = 0;
if (rx_ring_mode  3) {
DBG_PRINT(ERR_DBG, s2io: Requested ring mode not supported\n);
DBG_PRINT(ERR_DBG, s2io: Defaulting to 3-buffer mode\n);
@@ -7312,7 +7316,7 @@ int __init s2io_starter(void)
  * Description: This function is the cleanup routine for the driver. It 
unregist * ers the driver.
  */
 
-static void s2io_closer(void)
+static __exit void s2io_closer(void)
 {
pci_unregister_driver(s2io_driver);
DBG_PRINT(INIT_DBG, cleanup done\n);
@@ -7633,6 +7637,7 @@ static void lro_append_pkt(nic_t *sp, lr
lro-last_frag-next = skb;
else
skb_shinfo(first)-frag_list = skb;
+   first-truesize += skb-truesize;
lro-last_frag = skb;
sp-mac_control.stats_info-sw_stat.clubbed_frms_cnt++;
return;

-
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.20 4/5] s2io: Removed enabling of some of the unused interrupts.

2007-01-31 Thread Sivakumar Subramani
Removed unused code in en_dis_able_nic_intrs(), TX_DMA_INTR, RX_DMA_INTR,
TX_XGXS_INTR, MC_INTR

Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]
---
diff -urpN patch3/drivers/net/s2io.c patch4/drivers/net/s2io.c
--- patch3/drivers/net/s2io.c   2007-01-31 22:50:24.0 +0530
+++ patch4/drivers/net/s2io.c   2007-01-31 22:50:53.0 +0530
@@ -1658,7 +1658,7 @@ static void en_dis_able_nic_intrs(struct
/*  PIC Interrupts */
if ((mask  (TX_PIC_INTR | RX_PIC_INTR))) {
/*  Enable PIC Intrs in the general intr mask register */
-   val64 = TXPIC_INT_M | PIC_RX_INT_M;
+   val64 = TXPIC_INT_M;
if (flag == ENABLE_INTRS) {
temp64 = readq(bar0-general_int_mask);
temp64 = ~((u64) val64);
@@ -1696,70 +1696,6 @@ static void en_dis_able_nic_intrs(struct
}
}
 
-   /*  DMA Interrupts */
-   /*  Enabling/Disabling Tx DMA interrupts */
-   if (mask  TX_DMA_INTR) {
-   /* Enable TxDMA Intrs in the general intr mask register */
-   val64 = TXDMA_INT_M;
-   if (flag == ENABLE_INTRS) {
-   temp64 = readq(bar0-general_int_mask);
-   temp64 = ~((u64) val64);
-   writeq(temp64, bar0-general_int_mask);
-   /*
-* Keep all interrupts other than PFC interrupt
-* and PCC interrupt disabled in DMA level.
-*/
-   val64 = DISABLE_ALL_INTRS  ~(TXDMA_PFC_INT_M |
- TXDMA_PCC_INT_M);
-   writeq(val64, bar0-txdma_int_mask);
-   /*
-* Enable only the MISC error 1 interrupt in PFC block
-*/
-   val64 = DISABLE_ALL_INTRS  (~PFC_MISC_ERR_1);
-   writeq(val64, bar0-pfc_err_mask);
-   /*
-* Enable only the FB_ECC error interrupt in PCC block
-*/
-   val64 = DISABLE_ALL_INTRS  (~PCC_FB_ECC_ERR);
-   writeq(val64, bar0-pcc_err_mask);
-   } else if (flag == DISABLE_INTRS) {
-   /*
-* Disable TxDMA Intrs in the general intr mask
-* register
-*/
-   writeq(DISABLE_ALL_INTRS, bar0-txdma_int_mask);
-   writeq(DISABLE_ALL_INTRS, bar0-pfc_err_mask);
-   temp64 = readq(bar0-general_int_mask);
-   val64 |= temp64;
-   writeq(val64, bar0-general_int_mask);
-   }
-   }
-
-   /*  Enabling/Disabling Rx DMA interrupts */
-   if (mask  RX_DMA_INTR) {
-   /*  Enable RxDMA Intrs in the general intr mask register */
-   val64 = RXDMA_INT_M;
-   if (flag == ENABLE_INTRS) {
-   temp64 = readq(bar0-general_int_mask);
-   temp64 = ~((u64) val64);
-   writeq(temp64, bar0-general_int_mask);
-   /*
-* All RxDMA block interrupts are disabled for now
-* TODO
-*/
-   writeq(DISABLE_ALL_INTRS, bar0-rxdma_int_mask);
-   } else if (flag == DISABLE_INTRS) {
-   /*
-* Disable RxDMA Intrs in the general intr mask
-* register
-*/
-   writeq(DISABLE_ALL_INTRS, bar0-rxdma_int_mask);
-   temp64 = readq(bar0-general_int_mask);
-   val64 |= temp64;
-   writeq(val64, bar0-general_int_mask);
-   }
-   }
-
/*  MAC Interrupts */
/*  Enabling/Disabling MAC interrupts */
if (mask  (TX_MAC_INTR | RX_MAC_INTR)) {
@@ -1786,53 +1722,6 @@ static void en_dis_able_nic_intrs(struct
}
}
 
-   /*  XGXS Interrupts */
-   if (mask  (TX_XGXS_INTR | RX_XGXS_INTR)) {
-   val64 = TXXGXS_INT_M | RXXGXS_INT_M;
-   if (flag == ENABLE_INTRS) {
-   temp64 = readq(bar0-general_int_mask);
-   temp64 = ~((u64) val64);
-   writeq(temp64, bar0-general_int_mask);
-   /*
-* All XGXS block error interrupts are disabled for now
-* TODO
-*/
-   writeq(DISABLE_ALL_INTRS, bar0-xgxs_int_mask);
-   } else if (flag == DISABLE_INTRS) {
-   /*
-* Disable MC Intrs in the general intr mask register
-*/
-   writeq

RE: [PATCH 2.6.20 1/5] s2io: Making LRO and UFO as module loadable parameter.

2007-01-31 Thread Sivakumar Subramani
Hi Jeff,

Synced up the patches to the latest code from netdev#upstream branch and
also taken care of the Whitespaces. I have resubmitted all the five
patches again. Please apply it.

Thanks,
~Siva 

-Original Message-
From: Jeff Garzik [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 31, 2007 3:48 PM
To: Ananda Raju
Cc: netdev@vger.kernel.org; Leonid Grossman; Alicia Pena; Ramkrishna
Vepa; Sreenivasa Honnur; Sriram Rapuru; Sivakumar Subramani; Rastapur
Santosh
Subject: Re: [PATCH 2.6.20 1/5] s2io: Making LRO and UFO as module
loadable parameter.

Ananda Raju wrote:
 This patch adds two load parameters napi and ufo. Previously NAPI was 
 compilation option with these changes wan enable disable NAPI using 
 load parameter. Also we are introducing ufo load parameter to 
 enable/disable ufo feature
 
 Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]

ACK patches 1-5, but still problems:

1) does not apply to netdev#upstream

2) adds trailing whitespace


[EMAIL PROTECTED] netdev-2.6]$ git-am --signoff --utf8 /g/tmp/mbox

Applying 's2io: Making LRO and UFO as module loadable parameter.'

Adds trailing whitespace.
.dotest/patch:46:   }
Adds trailing whitespace.
.dotest/patch:209:
error: patch failed: drivers/net/s2io.c:6984
error: drivers/net/s2io.c: patch does not apply Patch failed at 0001.
When you have resolved this problem run git-am --resolved.
If you would prefer to skip this patch, instead run git-am --skip.
-
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.20 1/5] s2io: Making LRO and UFO as module loadable parameter.

2007-01-30 Thread Sivakumar Subramani
Hi Jeff,

Where you able to apply the patches. Please let me the known if you have
any issues.

Thanks,
~Siva 

-Original Message-
From: Sivakumar Subramani 
Sent: Monday, January 29, 2007 11:36 AM
To: netdev@vger.kernel.org; 'Jeff Garzik'
Cc: Leonid Grossman; Ananda Raju; Sreenivasa Honnur; Ramkrishna Vepa;
Rastapur Santosh; Sriram Rapuru
Subject: RE: [PATCH 2.6.20 1/5] s2io: Making LRO and UFO as module
loadable parameter.

 
Hi Jeff,

As per your comment I have synced up the patch with the latest
netdev-2.6.git#upstream branch. Also I have corrected the white space
issue. I have resubmitted the patches again.

Thanks,
~Siva
-Original Message-
From: Jeff Garzik [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 24, 2007 2:56 AM
To: Ananda Raju
Cc: [EMAIL PROTECTED]; Leonid Grossman; Alicia Pena; Ramkrishna
Vepa; Sreenivasa Honnur; Sriram Rapuru
Subject: Re: [PATCH 2.6.20 1/5] s2io: Making LRO and UFO as module
loadable parameter.

Ananda Raju wrote:
 This patch adds two load parameters napi and ufo. Previously NAPI was 
 compilation option with these changes wan enable disable NAPI using 
 load parameter. Also we are introducing ufo load parameter to 
 enable/disable ufo feature
 
 Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]

ACK patches 1-5, but patch does not apply to netdev-2.6.git#upstream. 
Also, git-am complains about whitespace.


[EMAIL PROTECTED] netdev-2.6]$ git-am --signoff --utf8 /g/tmp/mbox

Applying 's2io: Making LRO and UFO as module loadable parameter.'

Space in indent is followed by a tab.
.dotest/patch:41:   (block_no * 
(rxd_count[nic-rxd_mode] + 1)) + off;
Adds trailing whitespace.
.dotest/patch:46:   }
Space in indent is followed by a tab.
.dotest/patch:137:  * Rx handler is called by default, 
without checking for the
Space in indent is followed by a tab.
.dotest/patch:138:  * cause of interrupt.
Space in indent is followed by a tab.
.dotest/patch:139:  * rx_traffic_int reg is an R1 register, 
writing all 1's
error: patch failed: drivers/net/s2io.c:6985
error: drivers/net/s2io.c: patch does not apply Patch failed at 0001.
When you have resolved this problem run git-am --resolved.
If you would prefer to skip this patch, instead run git-am --skip.
-
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.20 1/5] s2io: Making LRO and UFO as module loadable parameter.

2007-01-28 Thread Sivakumar Subramani
 
Hi Jeff,

As per your comment I have synced up the patch with the latest
netdev-2.6.git#upstream branch. Also I have corrected the white space
issue. I have resubmitted the patches again.

Thanks,
~Siva
-Original Message-
From: Jeff Garzik [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 24, 2007 2:56 AM
To: Ananda Raju
Cc: [EMAIL PROTECTED]; Leonid Grossman; Alicia Pena; Ramkrishna
Vepa; Sreenivasa Honnur; Sriram Rapuru
Subject: Re: [PATCH 2.6.20 1/5] s2io: Making LRO and UFO as module
loadable parameter.

Ananda Raju wrote:
 This patch adds two load parameters napi and ufo. Previously NAPI was 
 compilation option with these changes wan enable disable NAPI using 
 load parameter. Also we are introducing ufo load parameter to 
 enable/disable ufo feature
 
 Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]

ACK patches 1-5, but patch does not apply to netdev-2.6.git#upstream. 
Also, git-am complains about whitespace.


[EMAIL PROTECTED] netdev-2.6]$ git-am --signoff --utf8 /g/tmp/mbox

Applying 's2io: Making LRO and UFO as module loadable parameter.'

Space in indent is followed by a tab.
.dotest/patch:41:   (block_no * 
(rxd_count[nic-rxd_mode] + 1)) + off;
Adds trailing whitespace.
.dotest/patch:46:   }
Space in indent is followed by a tab.
.dotest/patch:137:  * Rx handler is called by default, 
without checking for the
Space in indent is followed by a tab.
.dotest/patch:138:  * cause of interrupt.
Space in indent is followed by a tab.
.dotest/patch:139:  * rx_traffic_int reg is an R1 register, 
writing all 1's
error: patch failed: drivers/net/s2io.c:6985
error: drivers/net/s2io.c: patch does not apply Patch failed at 0001.
When you have resolved this problem run git-am --resolved.
If you would prefer to skip this patch, instead run git-am --skip.
-
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.20 5/5] s2io: De-typedef driver.

2007-01-23 Thread Sivakumar Subramani
Hi Jeff,

Thanks for the comments. We have implemented the comments and
resubmitted all five patch again.

Thanks,
~Siva 

-Original Message-
From: Jeff Garzik [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 23, 2007 11:18 AM
To: Ananda Raju
Cc: netdev@vger.kernel.org; Leonid Grossman; Alicia Pena; Ramkrishna
Vepa; Sivakumar Subramani; Sreenivasa Honnur; Sriram Rapuru
Subject: Re: [PATCH 2.6.20 5/5] s2io: De-typedef driver.

Ananda Raju wrote:
 Removed namespace collisions due to usage of nic_t as per Ralf's patch

 ([EMAIL PROTECTED]).
 
 Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]

ACK

Please make the following the first line of your email body:

From: Ralf Baechle [EMAIL PROTECTED]

That will tell the patch importer to properly credit Ralf as the patch's
author.

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


RE: [PATCH 2.6.20 1/5] s2io: updates for s2io driver.

2007-01-19 Thread Sivakumar Subramani
Hi Jeff,

Thanks for the comments and references.

As per you suggestion, we have resubmitted the patches with required
change.

Thanks,
~Siva 

-Original Message-
From: Jeff Garzik [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 18, 2007 10:32 PM
To: Ananda Raju
Cc: netdev@vger.kernel.org; Leonid Grossman; Sivakumar Subramani; Alicia
Pena; [EMAIL PROTECTED]; Ramkrishna Vepa
Subject: Re: [PATCH 2.6.20 1/5] s2io: updates for s2io driver.

Ananda Raju wrote:
 Hello,
 
 List of changes in this patch:
 
   This patch adds two load parameters napi and ufo. Previously
NAPI was 
 compilation option with these changes wan enable disable NAPI using 
 load parameter. Also we are introducing ufo load parameter to 
 enable/disable ufo feature
 
 Signed-off-by: Sivakumar Subramani [EMAIL PROTECTED]

OK, you're getting closer :)

Problems that need correcting:

1) Your email subject line is a one-line summary of the patch.  s2io: 
updates for s2io driver is useless, because it tells us nothing about
the patch itself.  When applied in a series,

git log master..upstream-fixes | git shortlog

will produce

Ananda Raju (5):
s2io: updates for s2io driver
s2io: updates for s2io driver
s2io: updates for s2io driver
s2io: updates for s2io driver
s2io: updates for s2io driver

which clearly makes it impossible to distinguish between changesets. 
Please re-read Rule #1 of http://linux.yyz.us/patch-format.html

Also, re-read Rule #2.  Everything in your email body before the --- 
terminator is copied DIRECTLY into the kernel changelog.  As such,
comments like Hello, and List of changes in this patch: must be
hand-edited out of your email, before applying the patch.

Please fix these problems and resubmit.

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