aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/s2io.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/s2io.c')
-rw-r--r--drivers/net/s2io.c794
1 files changed, 673 insertions, 121 deletions
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index dd451e099a4c..3f5e93aad5c7 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -65,9 +65,11 @@
65#include "s2io.h" 65#include "s2io.h"
66#include "s2io-regs.h" 66#include "s2io-regs.h"
67 67
68#define DRV_VERSION "Version 2.0.9.1"
69
68/* S2io Driver name & version. */ 70/* S2io Driver name & version. */
69static char s2io_driver_name[] = "Neterion"; 71static char s2io_driver_name[] = "Neterion";
70static char s2io_driver_version[] = "Version 2.0.8.1"; 72static char s2io_driver_version[] = DRV_VERSION;
71 73
72static inline int RXD_IS_UP2DT(RxD_t *rxdp) 74static inline int RXD_IS_UP2DT(RxD_t *rxdp)
73{ 75{
@@ -307,6 +309,8 @@ static unsigned int indicate_max_pkts;
307#endif 309#endif
308/* Frequency of Rx desc syncs expressed as power of 2 */ 310/* Frequency of Rx desc syncs expressed as power of 2 */
309static unsigned int rxsync_frequency = 3; 311static unsigned int rxsync_frequency = 3;
312/* Interrupt type. Values can be 0(INTA), 1(MSI), 2(MSI_X) */
313static unsigned int intr_type = 0;
310 314
311/* 315/*
312 * S2IO device table. 316 * S2IO device table.
@@ -701,8 +705,7 @@ static void free_shared_mem(struct s2io_nic *nic)
701 } 705 }
702 kfree(mac_control->rings[i].ba[j]); 706 kfree(mac_control->rings[i].ba[j]);
703 } 707 }
704 if (mac_control->rings[i].ba) 708 kfree(mac_control->rings[i].ba);
705 kfree(mac_control->rings[i].ba);
706 } 709 }
707#endif 710#endif
708 711
@@ -1396,8 +1399,13 @@ static int init_nic(struct s2io_nic *nic)
1396 writeq(val64, &bar0->rti_data1_mem); 1399 writeq(val64, &bar0->rti_data1_mem);
1397 1400
1398 val64 = RTI_DATA2_MEM_RX_UFC_A(0x1) | 1401 val64 = RTI_DATA2_MEM_RX_UFC_A(0x1) |
1399 RTI_DATA2_MEM_RX_UFC_B(0x2) | 1402 RTI_DATA2_MEM_RX_UFC_B(0x2) ;
1400 RTI_DATA2_MEM_RX_UFC_C(0x40) | RTI_DATA2_MEM_RX_UFC_D(0x80); 1403 if (nic->intr_type == MSI_X)
1404 val64 |= (RTI_DATA2_MEM_RX_UFC_C(0x20) | \
1405 RTI_DATA2_MEM_RX_UFC_D(0x40));
1406 else
1407 val64 |= (RTI_DATA2_MEM_RX_UFC_C(0x40) | \
1408 RTI_DATA2_MEM_RX_UFC_D(0x80));
1401 writeq(val64, &bar0->rti_data2_mem); 1409 writeq(val64, &bar0->rti_data2_mem);
1402 1410
1403 for (i = 0; i < config->rx_ring_num; i++) { 1411 for (i = 0; i < config->rx_ring_num; i++) {
@@ -1507,17 +1515,15 @@ static int init_nic(struct s2io_nic *nic)
1507#define LINK_UP_DOWN_INTERRUPT 1 1515#define LINK_UP_DOWN_INTERRUPT 1
1508#define MAC_RMAC_ERR_TIMER 2 1516#define MAC_RMAC_ERR_TIMER 2
1509 1517
1510#if defined(CONFIG_MSI_MODE) || defined(CONFIG_MSIX_MODE)
1511#define s2io_link_fault_indication(x) MAC_RMAC_ERR_TIMER
1512#else
1513int s2io_link_fault_indication(nic_t *nic) 1518int s2io_link_fault_indication(nic_t *nic)
1514{ 1519{
1520 if (nic->intr_type != INTA)
1521 return MAC_RMAC_ERR_TIMER;
1515 if (nic->device_type == XFRAME_II_DEVICE) 1522 if (nic->device_type == XFRAME_II_DEVICE)
1516 return LINK_UP_DOWN_INTERRUPT; 1523 return LINK_UP_DOWN_INTERRUPT;
1517 else 1524 else
1518 return MAC_RMAC_ERR_TIMER; 1525 return MAC_RMAC_ERR_TIMER;
1519} 1526}
1520#endif
1521 1527
1522/** 1528/**
1523 * en_dis_able_nic_intrs - Enable or Disable the interrupts 1529 * en_dis_able_nic_intrs - Enable or Disable the interrupts
@@ -1941,11 +1947,14 @@ static int start_nic(struct s2io_nic *nic)
1941 } 1947 }
1942 1948
1943 /* Enable select interrupts */ 1949 /* Enable select interrupts */
1944 interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR; 1950 if (nic->intr_type != INTA)
1945 interruptible |= TX_PIC_INTR | RX_PIC_INTR; 1951 en_dis_able_nic_intrs(nic, ENA_ALL_INTRS, DISABLE_INTRS);
1946 interruptible |= TX_MAC_INTR | RX_MAC_INTR; 1952 else {
1947 1953 interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR;
1948 en_dis_able_nic_intrs(nic, interruptible, ENABLE_INTRS); 1954 interruptible |= TX_PIC_INTR | RX_PIC_INTR;
1955 interruptible |= TX_MAC_INTR | RX_MAC_INTR;
1956 en_dis_able_nic_intrs(nic, interruptible, ENABLE_INTRS);
1957 }
1949 1958
1950 /* 1959 /*
1951 * With some switches, link might be already up at this point. 1960 * With some switches, link might be already up at this point.
@@ -2633,11 +2642,11 @@ static void tx_intr_handler(fifo_info_t *fifo_data)
2633 err = txdlp->Control_1 & TXD_T_CODE; 2642 err = txdlp->Control_1 & TXD_T_CODE;
2634 if ((err >> 48) == 0xA) { 2643 if ((err >> 48) == 0xA) {
2635 DBG_PRINT(TX_DBG, "TxD returned due \ 2644 DBG_PRINT(TX_DBG, "TxD returned due \
2636 to loss of link\n"); 2645to loss of link\n");
2637 } 2646 }
2638 else { 2647 else {
2639 DBG_PRINT(ERR_DBG, "***TxD error \ 2648 DBG_PRINT(ERR_DBG, "***TxD error \
2640 %llx\n", err); 2649%llx\n", err);
2641 } 2650 }
2642 } 2651 }
2643 2652
@@ -2854,6 +2863,9 @@ void s2io_reset(nic_t * sp)
2854 /* Set swapper to enable I/O register access */ 2863 /* Set swapper to enable I/O register access */
2855 s2io_set_swapper(sp); 2864 s2io_set_swapper(sp);
2856 2865
2866 /* Restore the MSIX table entries from local variables */
2867 restore_xmsi_data(sp);
2868
2857 /* Clear certain PCI/PCI-X fields after reset */ 2869 /* Clear certain PCI/PCI-X fields after reset */
2858 if (sp->device_type == XFRAME_II_DEVICE) { 2870 if (sp->device_type == XFRAME_II_DEVICE) {
2859 /* Clear parity err detect bit */ 2871 /* Clear parity err detect bit */
@@ -2983,8 +2995,9 @@ int s2io_set_swapper(nic_t * sp)
2983 SWAPPER_CTRL_RXD_W_FE | 2995 SWAPPER_CTRL_RXD_W_FE |
2984 SWAPPER_CTRL_RXF_W_FE | 2996 SWAPPER_CTRL_RXF_W_FE |
2985 SWAPPER_CTRL_XMSI_FE | 2997 SWAPPER_CTRL_XMSI_FE |
2986 SWAPPER_CTRL_XMSI_SE |
2987 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE); 2998 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE);
2999 if (sp->intr_type == INTA)
3000 val64 |= SWAPPER_CTRL_XMSI_SE;
2988 writeq(val64, &bar0->swapper_ctrl); 3001 writeq(val64, &bar0->swapper_ctrl);
2989#else 3002#else
2990 /* 3003 /*
@@ -3005,8 +3018,9 @@ int s2io_set_swapper(nic_t * sp)
3005 SWAPPER_CTRL_RXD_W_SE | 3018 SWAPPER_CTRL_RXD_W_SE |
3006 SWAPPER_CTRL_RXF_W_FE | 3019 SWAPPER_CTRL_RXF_W_FE |
3007 SWAPPER_CTRL_XMSI_FE | 3020 SWAPPER_CTRL_XMSI_FE |
3008 SWAPPER_CTRL_XMSI_SE |
3009 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE); 3021 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE);
3022 if (sp->intr_type == INTA)
3023 val64 |= SWAPPER_CTRL_XMSI_SE;
3010 writeq(val64, &bar0->swapper_ctrl); 3024 writeq(val64, &bar0->swapper_ctrl);
3011#endif 3025#endif
3012 val64 = readq(&bar0->swapper_ctrl); 3026 val64 = readq(&bar0->swapper_ctrl);
@@ -3028,6 +3042,201 @@ int s2io_set_swapper(nic_t * sp)
3028 return SUCCESS; 3042 return SUCCESS;
3029} 3043}
3030 3044
3045int wait_for_msix_trans(nic_t *nic, int i)
3046{
3047 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3048 u64 val64;
3049 int ret = 0, cnt = 0;
3050
3051 do {
3052 val64 = readq(&bar0->xmsi_access);
3053 if (!(val64 & BIT(15)))
3054 break;
3055 mdelay(1);
3056 cnt++;
3057 } while(cnt < 5);
3058 if (cnt == 5) {
3059 DBG_PRINT(ERR_DBG, "XMSI # %d Access failed\n", i);
3060 ret = 1;
3061 }
3062
3063 return ret;
3064}
3065
3066void restore_xmsi_data(nic_t *nic)
3067{
3068 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3069 u64 val64;
3070 int i;
3071
3072 for (i=0; i< MAX_REQUESTED_MSI_X; i++) {
3073 writeq(nic->msix_info[i].addr, &bar0->xmsi_address);
3074 writeq(nic->msix_info[i].data, &bar0->xmsi_data);
3075 val64 = (BIT(7) | BIT(15) | vBIT(i, 26, 6));
3076 writeq(val64, &bar0->xmsi_access);
3077 if (wait_for_msix_trans(nic, i)) {
3078 DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__);
3079 continue;
3080 }
3081 }
3082}
3083
3084void store_xmsi_data(nic_t *nic)
3085{
3086 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3087 u64 val64, addr, data;
3088 int i;
3089
3090 /* Store and display */
3091 for (i=0; i< MAX_REQUESTED_MSI_X; i++) {
3092 val64 = (BIT(15) | vBIT(i, 26, 6));
3093 writeq(val64, &bar0->xmsi_access);
3094 if (wait_for_msix_trans(nic, i)) {
3095 DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__);
3096 continue;
3097 }
3098 addr = readq(&bar0->xmsi_address);
3099 data = readq(&bar0->xmsi_data);
3100 if (addr && data) {
3101 nic->msix_info[i].addr = addr;
3102 nic->msix_info[i].data = data;
3103 }
3104 }
3105}
3106
3107int s2io_enable_msi(nic_t *nic)
3108{
3109 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3110 u16 msi_ctrl, msg_val;
3111 struct config_param *config = &nic->config;
3112 struct net_device *dev = nic->dev;
3113 u64 val64, tx_mat, rx_mat;
3114 int i, err;
3115
3116 val64 = readq(&bar0->pic_control);
3117 val64 &= ~BIT(1);
3118 writeq(val64, &bar0->pic_control);
3119
3120 err = pci_enable_msi(nic->pdev);
3121 if (err) {
3122 DBG_PRINT(ERR_DBG, "%s: enabling MSI failed\n",
3123 nic->dev->name);
3124 return err;
3125 }
3126
3127 /*
3128 * Enable MSI and use MSI-1 in stead of the standard MSI-0
3129 * for interrupt handling.
3130 */
3131 pci_read_config_word(nic->pdev, 0x4c, &msg_val);
3132 msg_val ^= 0x1;
3133 pci_write_config_word(nic->pdev, 0x4c, msg_val);
3134 pci_read_config_word(nic->pdev, 0x4c, &msg_val);
3135
3136 pci_read_config_word(nic->pdev, 0x42, &msi_ctrl);
3137 msi_ctrl |= 0x10;
3138 pci_write_config_word(nic->pdev, 0x42, msi_ctrl);
3139
3140 /* program MSI-1 into all usable Tx_Mat and Rx_Mat fields */
3141 tx_mat = readq(&bar0->tx_mat0_n[0]);
3142 for (i=0; i<config->tx_fifo_num; i++) {
3143 tx_mat |= TX_MAT_SET(i, 1);
3144 }
3145 writeq(tx_mat, &bar0->tx_mat0_n[0]);
3146
3147 rx_mat = readq(&bar0->rx_mat);
3148 for (i=0; i<config->rx_ring_num; i++) {
3149 rx_mat |= RX_MAT_SET(i, 1);
3150 }
3151 writeq(rx_mat, &bar0->rx_mat);
3152
3153 dev->irq = nic->pdev->irq;
3154 return 0;
3155}
3156
3157int s2io_enable_msi_x(nic_t *nic)
3158{
3159 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3160 u64 tx_mat, rx_mat;
3161 u16 msi_control; /* Temp variable */
3162 int ret, i, j, msix_indx = 1;
3163
3164 nic->entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry),
3165 GFP_KERNEL);
3166 if (nic->entries == NULL) {
3167 DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", __FUNCTION__);
3168 return -ENOMEM;
3169 }
3170 memset(nic->entries, 0, MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
3171
3172 nic->s2io_entries =
3173 kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry),
3174 GFP_KERNEL);
3175 if (nic->s2io_entries == NULL) {
3176 DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", __FUNCTION__);
3177 kfree(nic->entries);
3178 return -ENOMEM;
3179 }
3180 memset(nic->s2io_entries, 0,
3181 MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
3182
3183 for (i=0; i< MAX_REQUESTED_MSI_X; i++) {
3184 nic->entries[i].entry = i;
3185 nic->s2io_entries[i].entry = i;
3186 nic->s2io_entries[i].arg = NULL;
3187 nic->s2io_entries[i].in_use = 0;
3188 }
3189
3190 tx_mat = readq(&bar0->tx_mat0_n[0]);
3191 for (i=0; i<nic->config.tx_fifo_num; i++, msix_indx++) {
3192 tx_mat |= TX_MAT_SET(i, msix_indx);
3193 nic->s2io_entries[msix_indx].arg = &nic->mac_control.fifos[i];
3194 nic->s2io_entries[msix_indx].type = MSIX_FIFO_TYPE;
3195 nic->s2io_entries[msix_indx].in_use = MSIX_FLG;
3196 }
3197 writeq(tx_mat, &bar0->tx_mat0_n[0]);
3198
3199 if (!nic->config.bimodal) {
3200 rx_mat = readq(&bar0->rx_mat);
3201 for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) {
3202 rx_mat |= RX_MAT_SET(j, msix_indx);
3203 nic->s2io_entries[msix_indx].arg = &nic->mac_control.rings[j];
3204 nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE;
3205 nic->s2io_entries[msix_indx].in_use = MSIX_FLG;
3206 }
3207 writeq(rx_mat, &bar0->rx_mat);
3208 } else {
3209 tx_mat = readq(&bar0->tx_mat0_n[7]);
3210 for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) {
3211 tx_mat |= TX_MAT_SET(i, msix_indx);
3212 nic->s2io_entries[msix_indx].arg = &nic->mac_control.rings[j];
3213 nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE;
3214 nic->s2io_entries[msix_indx].in_use = MSIX_FLG;
3215 }
3216 writeq(tx_mat, &bar0->tx_mat0_n[7]);
3217 }
3218
3219 ret = pci_enable_msix(nic->pdev, nic->entries, MAX_REQUESTED_MSI_X);
3220 if (ret) {
3221 DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name);
3222 kfree(nic->entries);
3223 kfree(nic->s2io_entries);
3224 nic->entries = NULL;
3225 nic->s2io_entries = NULL;
3226 return -ENOMEM;
3227 }
3228
3229 /*
3230 * To enable MSI-X, MSI also needs to be enabled, due to a bug
3231 * in the herc NIC. (Temp change, needs to be removed later)
3232 */
3233 pci_read_config_word(nic->pdev, 0x42, &msi_control);
3234 msi_control |= 0x1; /* Enable MSI */
3235 pci_write_config_word(nic->pdev, 0x42, msi_control);
3236
3237 return 0;
3238}
3239
3031/* ********************************************************* * 3240/* ********************************************************* *
3032 * Functions defined below concern the OS part of the driver * 3241 * Functions defined below concern the OS part of the driver *
3033 * ********************************************************* */ 3242 * ********************************************************* */
@@ -3048,6 +3257,8 @@ int s2io_open(struct net_device *dev)
3048{ 3257{
3049 nic_t *sp = dev->priv; 3258 nic_t *sp = dev->priv;
3050 int err = 0; 3259 int err = 0;
3260 int i;
3261 u16 msi_control; /* Temp variable */
3051 3262
3052 /* 3263 /*
3053 * Make sure you have link off by default every time 3264 * Make sure you have link off by default every time
@@ -3064,13 +3275,55 @@ int s2io_open(struct net_device *dev)
3064 goto hw_init_failed; 3275 goto hw_init_failed;
3065 } 3276 }
3066 3277
3278 /* Store the values of the MSIX table in the nic_t structure */
3279 store_xmsi_data(sp);
3280
3067 /* After proper initialization of H/W, register ISR */ 3281 /* After proper initialization of H/W, register ISR */
3068 err = request_irq((int) sp->pdev->irq, s2io_isr, SA_SHIRQ, 3282 if (sp->intr_type == MSI) {
3069 sp->name, dev); 3283 err = request_irq((int) sp->pdev->irq, s2io_msi_handle,
3070 if (err) { 3284 SA_SHIRQ, sp->name, dev);
3071 DBG_PRINT(ERR_DBG, "%s: ISR registration failed\n", 3285 if (err) {
3072 dev->name); 3286 DBG_PRINT(ERR_DBG, "%s: MSI registration \
3073 goto isr_registration_failed; 3287failed\n", dev->name);
3288 goto isr_registration_failed;
3289 }
3290 }
3291 if (sp->intr_type == MSI_X) {
3292 for (i=1; (sp->s2io_entries[i].in_use == MSIX_FLG); i++) {
3293 if (sp->s2io_entries[i].type == MSIX_FIFO_TYPE) {
3294 sprintf(sp->desc1, "%s:MSI-X-%d-TX",
3295 dev->name, i);
3296 err = request_irq(sp->entries[i].vector,
3297 s2io_msix_fifo_handle, 0, sp->desc1,
3298 sp->s2io_entries[i].arg);
3299 DBG_PRINT(ERR_DBG, "%s @ 0x%llx\n", sp->desc1,
3300 sp->msix_info[i].addr);
3301 } else {
3302 sprintf(sp->desc2, "%s:MSI-X-%d-RX",
3303 dev->name, i);
3304 err = request_irq(sp->entries[i].vector,
3305 s2io_msix_ring_handle, 0, sp->desc2,
3306 sp->s2io_entries[i].arg);
3307 DBG_PRINT(ERR_DBG, "%s @ 0x%llx\n", sp->desc2,
3308 sp->msix_info[i].addr);
3309 }
3310 if (err) {
3311 DBG_PRINT(ERR_DBG, "%s: MSI-X-%d registration \
3312failed\n", dev->name, i);
3313 DBG_PRINT(ERR_DBG, "Returned: %d\n", err);
3314 goto isr_registration_failed;
3315 }
3316 sp->s2io_entries[i].in_use = MSIX_REGISTERED_SUCCESS;
3317 }
3318 }
3319 if (sp->intr_type == INTA) {
3320 err = request_irq((int) sp->pdev->irq, s2io_isr, SA_SHIRQ,
3321 sp->name, dev);
3322 if (err) {
3323 DBG_PRINT(ERR_DBG, "%s: ISR registration failed\n",
3324 dev->name);
3325 goto isr_registration_failed;
3326 }
3074 } 3327 }
3075 3328
3076 if (s2io_set_mac_addr(dev, dev->dev_addr) == FAILURE) { 3329 if (s2io_set_mac_addr(dev, dev->dev_addr) == FAILURE) {
@@ -3083,11 +3336,37 @@ int s2io_open(struct net_device *dev)
3083 return 0; 3336 return 0;
3084 3337
3085setting_mac_address_failed: 3338setting_mac_address_failed:
3086 free_irq(sp->pdev->irq, dev); 3339 if (sp->intr_type != MSI_X)
3340 free_irq(sp->pdev->irq, dev);
3087isr_registration_failed: 3341isr_registration_failed:
3088 del_timer_sync(&sp->alarm_timer); 3342 del_timer_sync(&sp->alarm_timer);
3343 if (sp->intr_type == MSI_X) {
3344 if (sp->device_type == XFRAME_II_DEVICE) {
3345 for (i=1; (sp->s2io_entries[i].in_use ==
3346 MSIX_REGISTERED_SUCCESS); i++) {
3347 int vector = sp->entries[i].vector;
3348 void *arg = sp->s2io_entries[i].arg;
3349
3350 free_irq(vector, arg);
3351 }
3352 pci_disable_msix(sp->pdev);
3353
3354 /* Temp */
3355 pci_read_config_word(sp->pdev, 0x42, &msi_control);
3356 msi_control &= 0xFFFE; /* Disable MSI */
3357 pci_write_config_word(sp->pdev, 0x42, msi_control);
3358 }
3359 }
3360 else if (sp->intr_type == MSI)
3361 pci_disable_msi(sp->pdev);
3089 s2io_reset(sp); 3362 s2io_reset(sp);
3090hw_init_failed: 3363hw_init_failed:
3364 if (sp->intr_type == MSI_X) {
3365 if (sp->entries)
3366 kfree(sp->entries);
3367 if (sp->s2io_entries)
3368 kfree(sp->s2io_entries);
3369 }
3091 return err; 3370 return err;
3092} 3371}
3093 3372
@@ -3107,12 +3386,35 @@ hw_init_failed:
3107int s2io_close(struct net_device *dev) 3386int s2io_close(struct net_device *dev)
3108{ 3387{
3109 nic_t *sp = dev->priv; 3388 nic_t *sp = dev->priv;
3389 int i;
3390 u16 msi_control;
3391
3110 flush_scheduled_work(); 3392 flush_scheduled_work();
3111 netif_stop_queue(dev); 3393 netif_stop_queue(dev);
3112 /* Reset card, kill tasklet and free Tx and Rx buffers. */ 3394 /* Reset card, kill tasklet and free Tx and Rx buffers. */
3113 s2io_card_down(sp); 3395 s2io_card_down(sp);
3114 3396
3115 free_irq(sp->pdev->irq, dev); 3397 if (sp->intr_type == MSI_X) {
3398 if (sp->device_type == XFRAME_II_DEVICE) {
3399 for (i=1; (sp->s2io_entries[i].in_use ==
3400 MSIX_REGISTERED_SUCCESS); i++) {
3401 int vector = sp->entries[i].vector;
3402 void *arg = sp->s2io_entries[i].arg;
3403
3404 free_irq(vector, arg);
3405 }
3406 pci_read_config_word(sp->pdev, 0x42, &msi_control);
3407 msi_control &= 0xFFFE; /* Disable MSI */
3408 pci_write_config_word(sp->pdev, 0x42, msi_control);
3409
3410 pci_disable_msix(sp->pdev);
3411 }
3412 }
3413 else {
3414 free_irq(sp->pdev->irq, dev);
3415 if (sp->intr_type == MSI)
3416 pci_disable_msi(sp->pdev);
3417 }
3116 sp->device_close_flag = TRUE; /* Device is shut down. */ 3418 sp->device_close_flag = TRUE; /* Device is shut down. */
3117 return 0; 3419 return 0;
3118} 3420}
@@ -3278,6 +3580,104 @@ s2io_alarm_handle(unsigned long data)
3278 mod_timer(&sp->alarm_timer, jiffies + HZ / 2); 3580 mod_timer(&sp->alarm_timer, jiffies + HZ / 2);
3279} 3581}
3280 3582
3583static irqreturn_t
3584s2io_msi_handle(int irq, void *dev_id, struct pt_regs *regs)
3585{
3586 struct net_device *dev = (struct net_device *) dev_id;
3587 nic_t *sp = dev->priv;
3588 int i;
3589 int ret;
3590 mac_info_t *mac_control;
3591 struct config_param *config;
3592
3593 atomic_inc(&sp->isr_cnt);
3594 mac_control = &sp->mac_control;
3595 config = &sp->config;
3596 DBG_PRINT(INTR_DBG, "%s: MSI handler\n", __FUNCTION__);
3597
3598 /* If Intr is because of Rx Traffic */
3599 for (i = 0; i < config->rx_ring_num; i++)
3600 rx_intr_handler(&mac_control->rings[i]);
3601
3602 /* If Intr is because of Tx Traffic */
3603 for (i = 0; i < config->tx_fifo_num; i++)
3604 tx_intr_handler(&mac_control->fifos[i]);
3605
3606 /*
3607 * If the Rx buffer count is below the panic threshold then
3608 * reallocate the buffers from the interrupt handler itself,
3609 * else schedule a tasklet to reallocate the buffers.
3610 */
3611 for (i = 0; i < config->rx_ring_num; i++) {
3612 int rxb_size = atomic_read(&sp->rx_bufs_left[i]);
3613 int level = rx_buffer_level(sp, rxb_size, i);
3614
3615 if ((level == PANIC) && (!TASKLET_IN_USE)) {
3616 DBG_PRINT(INTR_DBG, "%s: Rx BD hit ", dev->name);
3617 DBG_PRINT(INTR_DBG, "PANIC levels\n");
3618 if ((ret = fill_rx_buffers(sp, i)) == -ENOMEM) {
3619 DBG_PRINT(ERR_DBG, "%s:Out of memory",
3620 dev->name);
3621 DBG_PRINT(ERR_DBG, " in ISR!!\n");
3622 clear_bit(0, (&sp->tasklet_status));
3623 atomic_dec(&sp->isr_cnt);
3624 return IRQ_HANDLED;
3625 }
3626 clear_bit(0, (&sp->tasklet_status));
3627 } else if (level == LOW) {
3628 tasklet_schedule(&sp->task);
3629 }
3630 }
3631
3632 atomic_dec(&sp->isr_cnt);
3633 return IRQ_HANDLED;
3634}
3635
3636static irqreturn_t
3637s2io_msix_ring_handle(int irq, void *dev_id, struct pt_regs *regs)
3638{
3639 ring_info_t *ring = (ring_info_t *)dev_id;
3640 nic_t *sp = ring->nic;
3641 int rxb_size, level, rng_n;
3642
3643 atomic_inc(&sp->isr_cnt);
3644 rx_intr_handler(ring);
3645
3646 rng_n = ring->ring_no;
3647 rxb_size = atomic_read(&sp->rx_bufs_left[rng_n]);
3648 level = rx_buffer_level(sp, rxb_size, rng_n);
3649
3650 if ((level == PANIC) && (!TASKLET_IN_USE)) {
3651 int ret;
3652 DBG_PRINT(INTR_DBG, "%s: Rx BD hit ", __FUNCTION__);
3653 DBG_PRINT(INTR_DBG, "PANIC levels\n");
3654 if ((ret = fill_rx_buffers(sp, rng_n)) == -ENOMEM) {
3655 DBG_PRINT(ERR_DBG, "Out of memory in %s",
3656 __FUNCTION__);
3657 clear_bit(0, (&sp->tasklet_status));
3658 return IRQ_HANDLED;
3659 }
3660 clear_bit(0, (&sp->tasklet_status));
3661 } else if (level == LOW) {
3662 tasklet_schedule(&sp->task);
3663 }
3664 atomic_dec(&sp->isr_cnt);
3665
3666 return IRQ_HANDLED;
3667}
3668
3669static irqreturn_t
3670s2io_msix_fifo_handle(int irq, void *dev_id, struct pt_regs *regs)
3671{
3672 fifo_info_t *fifo = (fifo_info_t *)dev_id;
3673 nic_t *sp = fifo->nic;
3674
3675 atomic_inc(&sp->isr_cnt);
3676 tx_intr_handler(fifo);
3677 atomic_dec(&sp->isr_cnt);
3678 return IRQ_HANDLED;
3679}
3680
3281static void s2io_txpic_intr_handle(nic_t *sp) 3681static void s2io_txpic_intr_handle(nic_t *sp)
3282{ 3682{
3283 XENA_dev_config_t __iomem *bar0 = sp->bar0; 3683 XENA_dev_config_t __iomem *bar0 = sp->bar0;
@@ -3778,11 +4178,10 @@ static void s2io_ethtool_gdrvinfo(struct net_device *dev,
3778{ 4178{
3779 nic_t *sp = dev->priv; 4179 nic_t *sp = dev->priv;
3780 4180
3781 strncpy(info->driver, s2io_driver_name, sizeof(s2io_driver_name)); 4181 strncpy(info->driver, s2io_driver_name, sizeof(info->driver));
3782 strncpy(info->version, s2io_driver_version, 4182 strncpy(info->version, s2io_driver_version, sizeof(info->version));
3783 sizeof(s2io_driver_version)); 4183 strncpy(info->fw_version, "", sizeof(info->fw_version));
3784 strncpy(info->fw_version, "", 32); 4184 strncpy(info->bus_info, pci_name(sp->pdev), sizeof(info->bus_info));
3785 strncpy(info->bus_info, pci_name(sp->pdev), 32);
3786 info->regdump_len = XENA_REG_SPACE; 4185 info->regdump_len = XENA_REG_SPACE;
3787 info->eedump_len = XENA_EEPROM_SPACE; 4186 info->eedump_len = XENA_EEPROM_SPACE;
3788 info->testinfo_len = S2IO_TEST_LEN; 4187 info->testinfo_len = S2IO_TEST_LEN;
@@ -3978,29 +4377,53 @@ static int s2io_ethtool_setpause_data(struct net_device *dev,
3978 */ 4377 */
3979 4378
3980#define S2IO_DEV_ID 5 4379#define S2IO_DEV_ID 5
3981static int read_eeprom(nic_t * sp, int off, u32 * data) 4380static int read_eeprom(nic_t * sp, int off, u64 * data)
3982{ 4381{
3983 int ret = -1; 4382 int ret = -1;
3984 u32 exit_cnt = 0; 4383 u32 exit_cnt = 0;
3985 u64 val64; 4384 u64 val64;
3986 XENA_dev_config_t __iomem *bar0 = sp->bar0; 4385 XENA_dev_config_t __iomem *bar0 = sp->bar0;
3987 4386
3988 val64 = I2C_CONTROL_DEV_ID(S2IO_DEV_ID) | I2C_CONTROL_ADDR(off) | 4387 if (sp->device_type == XFRAME_I_DEVICE) {
3989 I2C_CONTROL_BYTE_CNT(0x3) | I2C_CONTROL_READ | 4388 val64 = I2C_CONTROL_DEV_ID(S2IO_DEV_ID) | I2C_CONTROL_ADDR(off) |
3990 I2C_CONTROL_CNTL_START; 4389 I2C_CONTROL_BYTE_CNT(0x3) | I2C_CONTROL_READ |
3991 SPECIAL_REG_WRITE(val64, &bar0->i2c_control, LF); 4390 I2C_CONTROL_CNTL_START;
4391 SPECIAL_REG_WRITE(val64, &bar0->i2c_control, LF);
3992 4392
3993 while (exit_cnt < 5) { 4393 while (exit_cnt < 5) {
3994 val64 = readq(&bar0->i2c_control); 4394 val64 = readq(&bar0->i2c_control);
3995 if (I2C_CONTROL_CNTL_END(val64)) { 4395 if (I2C_CONTROL_CNTL_END(val64)) {
3996 *data = I2C_CONTROL_GET_DATA(val64); 4396 *data = I2C_CONTROL_GET_DATA(val64);
3997 ret = 0; 4397 ret = 0;
3998 break; 4398 break;
4399 }
4400 msleep(50);
4401 exit_cnt++;
3999 } 4402 }
4000 msleep(50);
4001 exit_cnt++;
4002 } 4403 }
4003 4404
4405 if (sp->device_type == XFRAME_II_DEVICE) {
4406 val64 = SPI_CONTROL_KEY(0x9) | SPI_CONTROL_SEL1 |
4407 SPI_CONTROL_BYTECNT(0x3) |
4408 SPI_CONTROL_CMD(0x3) | SPI_CONTROL_ADDR(off);
4409 SPECIAL_REG_WRITE(val64, &bar0->spi_control, LF);
4410 val64 |= SPI_CONTROL_REQ;
4411 SPECIAL_REG_WRITE(val64, &bar0->spi_control, LF);
4412 while (exit_cnt < 5) {
4413 val64 = readq(&bar0->spi_control);
4414 if (val64 & SPI_CONTROL_NACK) {
4415 ret = 1;
4416 break;
4417 } else if (val64 & SPI_CONTROL_DONE) {
4418 *data = readq(&bar0->spi_data);
4419 *data &= 0xffffff;
4420 ret = 0;
4421 break;
4422 }
4423 msleep(50);
4424 exit_cnt++;
4425 }
4426 }
4004 return ret; 4427 return ret;
4005} 4428}
4006 4429
@@ -4019,28 +4442,53 @@ static int read_eeprom(nic_t * sp, int off, u32 * data)
4019 * 0 on success, -1 on failure. 4442 * 0 on success, -1 on failure.
4020 */ 4443 */
4021 4444
4022static int write_eeprom(nic_t * sp, int off, u32 data, int cnt) 4445static int write_eeprom(nic_t * sp, int off, u64 data, int cnt)
4023{ 4446{
4024 int exit_cnt = 0, ret = -1; 4447 int exit_cnt = 0, ret = -1;
4025 u64 val64; 4448 u64 val64;
4026 XENA_dev_config_t __iomem *bar0 = sp->bar0; 4449 XENA_dev_config_t __iomem *bar0 = sp->bar0;
4027 4450
4028 val64 = I2C_CONTROL_DEV_ID(S2IO_DEV_ID) | I2C_CONTROL_ADDR(off) | 4451 if (sp->device_type == XFRAME_I_DEVICE) {
4029 I2C_CONTROL_BYTE_CNT(cnt) | I2C_CONTROL_SET_DATA(data) | 4452 val64 = I2C_CONTROL_DEV_ID(S2IO_DEV_ID) | I2C_CONTROL_ADDR(off) |
4030 I2C_CONTROL_CNTL_START; 4453 I2C_CONTROL_BYTE_CNT(cnt) | I2C_CONTROL_SET_DATA((u32)data) |
4031 SPECIAL_REG_WRITE(val64, &bar0->i2c_control, LF); 4454 I2C_CONTROL_CNTL_START;
4455 SPECIAL_REG_WRITE(val64, &bar0->i2c_control, LF);
4456
4457 while (exit_cnt < 5) {
4458 val64 = readq(&bar0->i2c_control);
4459 if (I2C_CONTROL_CNTL_END(val64)) {
4460 if (!(val64 & I2C_CONTROL_NACK))
4461 ret = 0;
4462 break;
4463 }
4464 msleep(50);
4465 exit_cnt++;
4466 }
4467 }
4032 4468
4033 while (exit_cnt < 5) { 4469 if (sp->device_type == XFRAME_II_DEVICE) {
4034 val64 = readq(&bar0->i2c_control); 4470 int write_cnt = (cnt == 8) ? 0 : cnt;
4035 if (I2C_CONTROL_CNTL_END(val64)) { 4471 writeq(SPI_DATA_WRITE(data,(cnt<<3)), &bar0->spi_data);
4036 if (!(val64 & I2C_CONTROL_NACK)) 4472
4473 val64 = SPI_CONTROL_KEY(0x9) | SPI_CONTROL_SEL1 |
4474 SPI_CONTROL_BYTECNT(write_cnt) |
4475 SPI_CONTROL_CMD(0x2) | SPI_CONTROL_ADDR(off);
4476 SPECIAL_REG_WRITE(val64, &bar0->spi_control, LF);
4477 val64 |= SPI_CONTROL_REQ;
4478 SPECIAL_REG_WRITE(val64, &bar0->spi_control, LF);
4479 while (exit_cnt < 5) {
4480 val64 = readq(&bar0->spi_control);
4481 if (val64 & SPI_CONTROL_NACK) {
4482 ret = 1;
4483 break;
4484 } else if (val64 & SPI_CONTROL_DONE) {
4037 ret = 0; 4485 ret = 0;
4038 break; 4486 break;
4487 }
4488 msleep(50);
4489 exit_cnt++;
4039 } 4490 }
4040 msleep(50);
4041 exit_cnt++;
4042 } 4491 }
4043
4044 return ret; 4492 return ret;
4045} 4493}
4046 4494
@@ -4060,7 +4508,8 @@ static int write_eeprom(nic_t * sp, int off, u32 data, int cnt)
4060static int s2io_ethtool_geeprom(struct net_device *dev, 4508static int s2io_ethtool_geeprom(struct net_device *dev,
4061 struct ethtool_eeprom *eeprom, u8 * data_buf) 4509 struct ethtool_eeprom *eeprom, u8 * data_buf)
4062{ 4510{
4063 u32 data, i, valid; 4511 u32 i, valid;
4512 u64 data;
4064 nic_t *sp = dev->priv; 4513 nic_t *sp = dev->priv;
4065 4514
4066 eeprom->magic = sp->pdev->vendor | (sp->pdev->device << 16); 4515 eeprom->magic = sp->pdev->vendor | (sp->pdev->device << 16);
@@ -4098,7 +4547,7 @@ static int s2io_ethtool_seeprom(struct net_device *dev,
4098 u8 * data_buf) 4547 u8 * data_buf)
4099{ 4548{
4100 int len = eeprom->len, cnt = 0; 4549 int len = eeprom->len, cnt = 0;
4101 u32 valid = 0, data; 4550 u64 valid = 0, data;
4102 nic_t *sp = dev->priv; 4551 nic_t *sp = dev->priv;
4103 4552
4104 if (eeprom->magic != (sp->pdev->vendor | (sp->pdev->device << 16))) { 4553 if (eeprom->magic != (sp->pdev->vendor | (sp->pdev->device << 16))) {
@@ -4146,7 +4595,7 @@ static int s2io_ethtool_seeprom(struct net_device *dev,
4146static int s2io_register_test(nic_t * sp, uint64_t * data) 4595static int s2io_register_test(nic_t * sp, uint64_t * data)
4147{ 4596{
4148 XENA_dev_config_t __iomem *bar0 = sp->bar0; 4597 XENA_dev_config_t __iomem *bar0 = sp->bar0;
4149 u64 val64 = 0; 4598 u64 val64 = 0, exp_val;
4150 int fail = 0; 4599 int fail = 0;
4151 4600
4152 val64 = readq(&bar0->pif_rd_swapper_fb); 4601 val64 = readq(&bar0->pif_rd_swapper_fb);
@@ -4162,7 +4611,11 @@ static int s2io_register_test(nic_t * sp, uint64_t * data)
4162 } 4611 }
4163 4612
4164 val64 = readq(&bar0->rx_queue_cfg); 4613 val64 = readq(&bar0->rx_queue_cfg);
4165 if (val64 != 0x0808080808080808ULL) { 4614 if (sp->device_type == XFRAME_II_DEVICE)
4615 exp_val = 0x0404040404040404ULL;
4616 else
4617 exp_val = 0x0808080808080808ULL;
4618 if (val64 != exp_val) {
4166 fail = 1; 4619 fail = 1;
4167 DBG_PRINT(INFO_DBG, "Read Test level 3 fails\n"); 4620 DBG_PRINT(INFO_DBG, "Read Test level 3 fails\n");
4168 } 4621 }
@@ -4190,7 +4643,7 @@ static int s2io_register_test(nic_t * sp, uint64_t * data)
4190 } 4643 }
4191 4644
4192 *data = fail; 4645 *data = fail;
4193 return 0; 4646 return fail;
4194} 4647}
4195 4648
4196/** 4649/**
@@ -4209,58 +4662,83 @@ static int s2io_register_test(nic_t * sp, uint64_t * data)
4209static int s2io_eeprom_test(nic_t * sp, uint64_t * data) 4662static int s2io_eeprom_test(nic_t * sp, uint64_t * data)
4210{ 4663{
4211 int fail = 0; 4664 int fail = 0;
4212 u32 ret_data; 4665 u64 ret_data, org_4F0, org_7F0;
4666 u8 saved_4F0 = 0, saved_7F0 = 0;
4667 struct net_device *dev = sp->dev;
4213 4668
4214 /* Test Write Error at offset 0 */ 4669 /* Test Write Error at offset 0 */
4215 if (!write_eeprom(sp, 0, 0, 3)) 4670 /* Note that SPI interface allows write access to all areas
4216 fail = 1; 4671 * of EEPROM. Hence doing all negative testing only for Xframe I.
4672 */
4673 if (sp->device_type == XFRAME_I_DEVICE)
4674 if (!write_eeprom(sp, 0, 0, 3))
4675 fail = 1;
4676
4677 /* Save current values at offsets 0x4F0 and 0x7F0 */
4678 if (!read_eeprom(sp, 0x4F0, &org_4F0))
4679 saved_4F0 = 1;
4680 if (!read_eeprom(sp, 0x7F0, &org_7F0))
4681 saved_7F0 = 1;
4217 4682
4218 /* Test Write at offset 4f0 */ 4683 /* Test Write at offset 4f0 */
4219 if (write_eeprom(sp, 0x4F0, 0x01234567, 3)) 4684 if (write_eeprom(sp, 0x4F0, 0x012345, 3))
4220 fail = 1; 4685 fail = 1;
4221 if (read_eeprom(sp, 0x4F0, &ret_data)) 4686 if (read_eeprom(sp, 0x4F0, &ret_data))
4222 fail = 1; 4687 fail = 1;
4223 4688
4224 if (ret_data != 0x01234567) 4689 if (ret_data != 0x012345) {
4690 DBG_PRINT(ERR_DBG, "%s: eeprom test error at offset 0x4F0. Data written %llx Data read %llx\n", dev->name, (u64)0x12345, ret_data);
4225 fail = 1; 4691 fail = 1;
4692 }
4226 4693
4227 /* Reset the EEPROM data go FFFF */ 4694 /* Reset the EEPROM data go FFFF */
4228 write_eeprom(sp, 0x4F0, 0xFFFFFFFF, 3); 4695 write_eeprom(sp, 0x4F0, 0xFFFFFF, 3);
4229 4696
4230 /* Test Write Request Error at offset 0x7c */ 4697 /* Test Write Request Error at offset 0x7c */
4231 if (!write_eeprom(sp, 0x07C, 0, 3)) 4698 if (sp->device_type == XFRAME_I_DEVICE)
4232 fail = 1; 4699 if (!write_eeprom(sp, 0x07C, 0, 3))
4700 fail = 1;
4233 4701
4234 /* Test Write Request at offset 0x7fc */ 4702 /* Test Write Request at offset 0x7f0 */
4235 if (write_eeprom(sp, 0x7FC, 0x01234567, 3)) 4703 if (write_eeprom(sp, 0x7F0, 0x012345, 3))
4236 fail = 1; 4704 fail = 1;
4237 if (read_eeprom(sp, 0x7FC, &ret_data)) 4705 if (read_eeprom(sp, 0x7F0, &ret_data))
4238 fail = 1; 4706 fail = 1;
4239 4707
4240 if (ret_data != 0x01234567) 4708 if (ret_data != 0x012345) {
4709 DBG_PRINT(ERR_DBG, "%s: eeprom test error at offset 0x7F0. Data written %llx Data read %llx\n", dev->name, (u64)0x12345, ret_data);
4241 fail = 1; 4710 fail = 1;
4711 }
4242 4712
4243 /* Reset the EEPROM data go FFFF */ 4713 /* Reset the EEPROM data go FFFF */
4244 write_eeprom(sp, 0x7FC, 0xFFFFFFFF, 3); 4714 write_eeprom(sp, 0x7F0, 0xFFFFFF, 3);
4245 4715
4246 /* Test Write Error at offset 0x80 */ 4716 if (sp->device_type == XFRAME_I_DEVICE) {
4247 if (!write_eeprom(sp, 0x080, 0, 3)) 4717 /* Test Write Error at offset 0x80 */
4248 fail = 1; 4718 if (!write_eeprom(sp, 0x080, 0, 3))
4719 fail = 1;
4249 4720
4250 /* Test Write Error at offset 0xfc */ 4721 /* Test Write Error at offset 0xfc */
4251 if (!write_eeprom(sp, 0x0FC, 0, 3)) 4722 if (!write_eeprom(sp, 0x0FC, 0, 3))
4252 fail = 1; 4723 fail = 1;
4253 4724
4254 /* Test Write Error at offset 0x100 */ 4725 /* Test Write Error at offset 0x100 */
4255 if (!write_eeprom(sp, 0x100, 0, 3)) 4726 if (!write_eeprom(sp, 0x100, 0, 3))
4256 fail = 1; 4727 fail = 1;
4257 4728
4258 /* Test Write Error at offset 4ec */ 4729 /* Test Write Error at offset 4ec */
4259 if (!write_eeprom(sp, 0x4EC, 0, 3)) 4730 if (!write_eeprom(sp, 0x4EC, 0, 3))
4260 fail = 1; 4731 fail = 1;
4732 }
4733
4734 /* Restore values at offsets 0x4F0 and 0x7F0 */
4735 if (saved_4F0)
4736 write_eeprom(sp, 0x4F0, org_4F0, 3);
4737 if (saved_7F0)
4738 write_eeprom(sp, 0x7F0, org_7F0, 3);
4261 4739
4262 *data = fail; 4740 *data = fail;
4263 return 0; 4741 return fail;
4264} 4742}
4265 4743
4266/** 4744/**
@@ -4342,7 +4820,7 @@ static int s2io_rldram_test(nic_t * sp, uint64_t * data)
4342{ 4820{
4343 XENA_dev_config_t __iomem *bar0 = sp->bar0; 4821 XENA_dev_config_t __iomem *bar0 = sp->bar0;
4344 u64 val64; 4822 u64 val64;
4345 int cnt, iteration = 0, test_pass = 0; 4823 int cnt, iteration = 0, test_fail = 0;
4346 4824
4347 val64 = readq(&bar0->adapter_control); 4825 val64 = readq(&bar0->adapter_control);
4348 val64 &= ~ADAPTER_ECC_EN; 4826 val64 &= ~ADAPTER_ECC_EN;
@@ -4350,7 +4828,7 @@ static int s2io_rldram_test(nic_t * sp, uint64_t * data)
4350 4828
4351 val64 = readq(&bar0->mc_rldram_test_ctrl); 4829 val64 = readq(&bar0->mc_rldram_test_ctrl);
4352 val64 |= MC_RLDRAM_TEST_MODE; 4830 val64 |= MC_RLDRAM_TEST_MODE;
4353 writeq(val64, &bar0->mc_rldram_test_ctrl); 4831 SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_test_ctrl, LF);
4354 4832
4355 val64 = readq(&bar0->mc_rldram_mrs); 4833 val64 = readq(&bar0->mc_rldram_mrs);
4356 val64 |= MC_RLDRAM_QUEUE_SIZE_ENABLE; 4834 val64 |= MC_RLDRAM_QUEUE_SIZE_ENABLE;
@@ -4378,17 +4856,12 @@ static int s2io_rldram_test(nic_t * sp, uint64_t * data)
4378 } 4856 }
4379 writeq(val64, &bar0->mc_rldram_test_d2); 4857 writeq(val64, &bar0->mc_rldram_test_d2);
4380 4858
4381 val64 = (u64) (0x0000003fffff0000ULL); 4859 val64 = (u64) (0x0000003ffffe0100ULL);
4382 writeq(val64, &bar0->mc_rldram_test_add); 4860 writeq(val64, &bar0->mc_rldram_test_add);
4383 4861
4384 4862 val64 = MC_RLDRAM_TEST_MODE | MC_RLDRAM_TEST_WRITE |
4385 val64 = MC_RLDRAM_TEST_MODE; 4863 MC_RLDRAM_TEST_GO;
4386 writeq(val64, &bar0->mc_rldram_test_ctrl); 4864 SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_test_ctrl, LF);
4387
4388 val64 |=
4389 MC_RLDRAM_TEST_MODE | MC_RLDRAM_TEST_WRITE |
4390 MC_RLDRAM_TEST_GO;
4391 writeq(val64, &bar0->mc_rldram_test_ctrl);
4392 4865
4393 for (cnt = 0; cnt < 5; cnt++) { 4866 for (cnt = 0; cnt < 5; cnt++) {
4394 val64 = readq(&bar0->mc_rldram_test_ctrl); 4867 val64 = readq(&bar0->mc_rldram_test_ctrl);
@@ -4400,11 +4873,8 @@ static int s2io_rldram_test(nic_t * sp, uint64_t * data)
4400 if (cnt == 5) 4873 if (cnt == 5)
4401 break; 4874 break;
4402 4875
4403 val64 = MC_RLDRAM_TEST_MODE; 4876 val64 = MC_RLDRAM_TEST_MODE | MC_RLDRAM_TEST_GO;
4404 writeq(val64, &bar0->mc_rldram_test_ctrl); 4877 SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_test_ctrl, LF);
4405
4406 val64 |= MC_RLDRAM_TEST_MODE | MC_RLDRAM_TEST_GO;
4407 writeq(val64, &bar0->mc_rldram_test_ctrl);
4408 4878
4409 for (cnt = 0; cnt < 5; cnt++) { 4879 for (cnt = 0; cnt < 5; cnt++) {
4410 val64 = readq(&bar0->mc_rldram_test_ctrl); 4880 val64 = readq(&bar0->mc_rldram_test_ctrl);
@@ -4417,18 +4887,18 @@ static int s2io_rldram_test(nic_t * sp, uint64_t * data)
4417 break; 4887 break;
4418 4888
4419 val64 = readq(&bar0->mc_rldram_test_ctrl); 4889 val64 = readq(&bar0->mc_rldram_test_ctrl);
4420 if (val64 & MC_RLDRAM_TEST_PASS) 4890 if (!(val64 & MC_RLDRAM_TEST_PASS))
4421 test_pass = 1; 4891 test_fail = 1;
4422 4892
4423 iteration++; 4893 iteration++;
4424 } 4894 }
4425 4895
4426 if (!test_pass) 4896 *data = test_fail;
4427 *data = 1;
4428 else
4429 *data = 0;
4430 4897
4431 return 0; 4898 /* Bring the adapter out of test mode */
4899 SPECIAL_REG_WRITE(0, &bar0->mc_rldram_test_ctrl, LF);
4900
4901 return test_fail;
4432} 4902}
4433 4903
4434/** 4904/**
@@ -4932,7 +5402,7 @@ static void s2io_card_down(nic_t * sp)
4932 5402
4933static int s2io_card_up(nic_t * sp) 5403static int s2io_card_up(nic_t * sp)
4934{ 5404{
4935 int i, ret; 5405 int i, ret = 0;
4936 mac_info_t *mac_control; 5406 mac_info_t *mac_control;
4937 struct config_param *config; 5407 struct config_param *config;
4938 struct net_device *dev = (struct net_device *) sp->dev; 5408 struct net_device *dev = (struct net_device *) sp->dev;
@@ -4944,6 +5414,15 @@ static int s2io_card_up(nic_t * sp)
4944 return -ENODEV; 5414 return -ENODEV;
4945 } 5415 }
4946 5416
5417 if (sp->intr_type == MSI)
5418 ret = s2io_enable_msi(sp);
5419 else if (sp->intr_type == MSI_X)
5420 ret = s2io_enable_msi_x(sp);
5421 if (ret) {
5422 DBG_PRINT(ERR_DBG, "%s: Defaulting to INTA\n", dev->name);
5423 sp->intr_type = INTA;
5424 }
5425
4947 /* 5426 /*
4948 * Initializing the Rx buffers. For now we are considering only 1 5427 * Initializing the Rx buffers. For now we are considering only 1
4949 * Rx ring and initializing buffers into 30 Rx blocks 5428 * Rx ring and initializing buffers into 30 Rx blocks
@@ -5228,6 +5707,8 @@ static void s2io_init_pci(nic_t * sp)
5228 5707
5229MODULE_AUTHOR("Raghavendra Koushik <raghavendra.koushik@neterion.com>"); 5708MODULE_AUTHOR("Raghavendra Koushik <raghavendra.koushik@neterion.com>");
5230MODULE_LICENSE("GPL"); 5709MODULE_LICENSE("GPL");
5710MODULE_VERSION(DRV_VERSION);
5711
5231module_param(tx_fifo_num, int, 0); 5712module_param(tx_fifo_num, int, 0);
5232module_param(rx_ring_num, int, 0); 5713module_param(rx_ring_num, int, 0);
5233module_param_array(tx_fifo_len, uint, NULL, 0); 5714module_param_array(tx_fifo_len, uint, NULL, 0);
@@ -5245,6 +5726,7 @@ module_param(bimodal, bool, 0);
5245module_param(indicate_max_pkts, int, 0); 5726module_param(indicate_max_pkts, int, 0);
5246#endif 5727#endif
5247module_param(rxsync_frequency, int, 0); 5728module_param(rxsync_frequency, int, 0);
5729module_param(intr_type, int, 0);
5248 5730
5249/** 5731/**
5250 * s2io_init_nic - Initialization of the adapter . 5732 * s2io_init_nic - Initialization of the adapter .
@@ -5274,9 +5756,16 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5274 mac_info_t *mac_control; 5756 mac_info_t *mac_control;
5275 struct config_param *config; 5757 struct config_param *config;
5276 int mode; 5758 int mode;
5759 u8 dev_intr_type = intr_type;
5277 5760
5278#ifdef CONFIG_S2IO_NAPI 5761#ifdef CONFIG_S2IO_NAPI
5279 DBG_PRINT(ERR_DBG, "NAPI support has been enabled\n"); 5762 if (dev_intr_type != INTA) {
5763 DBG_PRINT(ERR_DBG, "NAPI cannot be enabled when MSI/MSI-X \
5764is enabled. Defaulting to INTA\n");
5765 dev_intr_type = INTA;
5766 }
5767 else
5768 DBG_PRINT(ERR_DBG, "NAPI support has been enabled\n");
5280#endif 5769#endif
5281 5770
5282 if ((ret = pci_enable_device(pdev))) { 5771 if ((ret = pci_enable_device(pdev))) {
@@ -5303,10 +5792,35 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5303 return -ENOMEM; 5792 return -ENOMEM;
5304 } 5793 }
5305 5794
5306 if (pci_request_regions(pdev, s2io_driver_name)) { 5795 if ((dev_intr_type == MSI_X) &&
5307 DBG_PRINT(ERR_DBG, "Request Regions failed\n"), 5796 ((pdev->device != PCI_DEVICE_ID_HERC_WIN) &&
5308 pci_disable_device(pdev); 5797 (pdev->device != PCI_DEVICE_ID_HERC_UNI))) {
5309 return -ENODEV; 5798 DBG_PRINT(ERR_DBG, "Xframe I does not support MSI_X. \
5799Defaulting to INTA\n");
5800 dev_intr_type = INTA;
5801 }
5802 if (dev_intr_type != MSI_X) {
5803 if (pci_request_regions(pdev, s2io_driver_name)) {
5804 DBG_PRINT(ERR_DBG, "Request Regions failed\n"),
5805 pci_disable_device(pdev);
5806 return -ENODEV;
5807 }
5808 }
5809 else {
5810 if (!(request_mem_region(pci_resource_start(pdev, 0),
5811 pci_resource_len(pdev, 0), s2io_driver_name))) {
5812 DBG_PRINT(ERR_DBG, "bar0 Request Regions failed\n");
5813 pci_disable_device(pdev);
5814 return -ENODEV;
5815 }
5816 if (!(request_mem_region(pci_resource_start(pdev, 2),
5817 pci_resource_len(pdev, 2), s2io_driver_name))) {
5818 DBG_PRINT(ERR_DBG, "bar1 Request Regions failed\n");
5819 release_mem_region(pci_resource_start(pdev, 0),
5820 pci_resource_len(pdev, 0));
5821 pci_disable_device(pdev);
5822 return -ENODEV;
5823 }
5310 } 5824 }
5311 5825
5312 dev = alloc_etherdev(sizeof(nic_t)); 5826 dev = alloc_etherdev(sizeof(nic_t));
@@ -5329,6 +5843,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5329 sp->pdev = pdev; 5843 sp->pdev = pdev;
5330 sp->high_dma_flag = dma_flag; 5844 sp->high_dma_flag = dma_flag;
5331 sp->device_enabled_once = FALSE; 5845 sp->device_enabled_once = FALSE;
5846 sp->intr_type = dev_intr_type;
5332 5847
5333 if ((pdev->device == PCI_DEVICE_ID_HERC_WIN) || 5848 if ((pdev->device == PCI_DEVICE_ID_HERC_WIN) ||
5334 (pdev->device == PCI_DEVICE_ID_HERC_UNI)) 5849 (pdev->device == PCI_DEVICE_ID_HERC_UNI))
@@ -5336,6 +5851,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5336 else 5851 else
5337 sp->device_type = XFRAME_I_DEVICE; 5852 sp->device_type = XFRAME_I_DEVICE;
5338 5853
5854
5339 /* Initialize some PCI/PCI-X fields of the NIC. */ 5855 /* Initialize some PCI/PCI-X fields of the NIC. */
5340 s2io_init_pci(sp); 5856 s2io_init_pci(sp);
5341 5857
@@ -5571,12 +6087,23 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5571 if (sp->device_type & XFRAME_II_DEVICE) { 6087 if (sp->device_type & XFRAME_II_DEVICE) {
5572 DBG_PRINT(ERR_DBG, "%s: Neterion Xframe II 10GbE adapter ", 6088 DBG_PRINT(ERR_DBG, "%s: Neterion Xframe II 10GbE adapter ",
5573 dev->name); 6089 dev->name);
5574 DBG_PRINT(ERR_DBG, "(rev %d), %s", 6090 DBG_PRINT(ERR_DBG, "(rev %d), Version %s",
5575 get_xena_rev_id(sp->pdev), 6091 get_xena_rev_id(sp->pdev),
5576 s2io_driver_version); 6092 s2io_driver_version);
5577#ifdef CONFIG_2BUFF_MODE 6093#ifdef CONFIG_2BUFF_MODE
5578 DBG_PRINT(ERR_DBG, ", Buffer mode %d",2); 6094 DBG_PRINT(ERR_DBG, ", Buffer mode %d",2);
5579#endif 6095#endif
6096 switch(sp->intr_type) {
6097 case INTA:
6098 DBG_PRINT(ERR_DBG, ", Intr type INTA");
6099 break;
6100 case MSI:
6101 DBG_PRINT(ERR_DBG, ", Intr type MSI");
6102 break;
6103 case MSI_X:
6104 DBG_PRINT(ERR_DBG, ", Intr type MSI-X");
6105 break;
6106 }
5580 6107
5581 DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n"); 6108 DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n");
5582 DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n", 6109 DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n",
@@ -5595,12 +6122,23 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5595 } else { 6122 } else {
5596 DBG_PRINT(ERR_DBG, "%s: Neterion Xframe I 10GbE adapter ", 6123 DBG_PRINT(ERR_DBG, "%s: Neterion Xframe I 10GbE adapter ",
5597 dev->name); 6124 dev->name);
5598 DBG_PRINT(ERR_DBG, "(rev %d), %s", 6125 DBG_PRINT(ERR_DBG, "(rev %d), Version %s",
5599 get_xena_rev_id(sp->pdev), 6126 get_xena_rev_id(sp->pdev),
5600 s2io_driver_version); 6127 s2io_driver_version);
5601#ifdef CONFIG_2BUFF_MODE 6128#ifdef CONFIG_2BUFF_MODE
5602 DBG_PRINT(ERR_DBG, ", Buffer mode %d",2); 6129 DBG_PRINT(ERR_DBG, ", Buffer mode %d",2);
5603#endif 6130#endif
6131 switch(sp->intr_type) {
6132 case INTA:
6133 DBG_PRINT(ERR_DBG, ", Intr type INTA");
6134 break;
6135 case MSI:
6136 DBG_PRINT(ERR_DBG, ", Intr type MSI");
6137 break;
6138 case MSI_X:
6139 DBG_PRINT(ERR_DBG, ", Intr type MSI-X");
6140 break;
6141 }
5604 DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n"); 6142 DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n");
5605 DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n", 6143 DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n",
5606 sp->def_mac_addr[0].mac_addr[0], 6144 sp->def_mac_addr[0].mac_addr[0],
@@ -5644,7 +6182,14 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5644 mem_alloc_failed: 6182 mem_alloc_failed:
5645 free_shared_mem(sp); 6183 free_shared_mem(sp);
5646 pci_disable_device(pdev); 6184 pci_disable_device(pdev);
5647 pci_release_regions(pdev); 6185 if (dev_intr_type != MSI_X)
6186 pci_release_regions(pdev);
6187 else {
6188 release_mem_region(pci_resource_start(pdev, 0),
6189 pci_resource_len(pdev, 0));
6190 release_mem_region(pci_resource_start(pdev, 2),
6191 pci_resource_len(pdev, 2));
6192 }
5648 pci_set_drvdata(pdev, NULL); 6193 pci_set_drvdata(pdev, NULL);
5649 free_netdev(dev); 6194 free_netdev(dev);
5650 6195
@@ -5678,7 +6223,14 @@ static void __devexit s2io_rem_nic(struct pci_dev *pdev)
5678 iounmap(sp->bar0); 6223 iounmap(sp->bar0);
5679 iounmap(sp->bar1); 6224 iounmap(sp->bar1);
5680 pci_disable_device(pdev); 6225 pci_disable_device(pdev);
5681 pci_release_regions(pdev); 6226 if (sp->intr_type != MSI_X)
6227 pci_release_regions(pdev);
6228 else {
6229 release_mem_region(pci_resource_start(pdev, 0),
6230 pci_resource_len(pdev, 0));
6231 release_mem_region(pci_resource_start(pdev, 2),
6232 pci_resource_len(pdev, 2));
6233 }
5682 pci_set_drvdata(pdev, NULL); 6234 pci_set_drvdata(pdev, NULL);
5683 free_netdev(dev); 6235 free_netdev(dev);
5684} 6236}