aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/s2io.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-05-29 10:05:05 -0400
committerIngo Molnar <mingo@elte.hu>2008-05-29 10:05:05 -0400
commit6715930654e06c4d2e66e718ea159079f71838f4 (patch)
tree6a0a19fb62f3e99cb5f6bf6c34ae541f7c30fb42 /drivers/net/s2io.c
parentea3f01f8afd3bc5daff915cc4ea5cc5ea9e7d427 (diff)
parente490517a039a99d692cb3a5561941b0a5f576172 (diff)
Merge commit 'linus/master' into sched-fixes-for-linus
Diffstat (limited to 'drivers/net/s2io.c')
-rw-r--r--drivers/net/s2io.c494
1 files changed, 293 insertions, 201 deletions
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 523478ebfd69..a20693e09ae8 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -86,7 +86,7 @@
86#include "s2io.h" 86#include "s2io.h"
87#include "s2io-regs.h" 87#include "s2io-regs.h"
88 88
89#define DRV_VERSION "2.0.26.23" 89#define DRV_VERSION "2.0.26.24"
90 90
91/* S2io Driver name & version. */ 91/* S2io Driver name & version. */
92static char s2io_driver_name[] = "Neterion"; 92static char s2io_driver_name[] = "Neterion";
@@ -1113,9 +1113,10 @@ static int s2io_on_nec_bridge(struct pci_dev *s2io_pdev)
1113 struct pci_dev *tdev = NULL; 1113 struct pci_dev *tdev = NULL;
1114 while ((tdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, tdev)) != NULL) { 1114 while ((tdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, tdev)) != NULL) {
1115 if (tdev->vendor == NEC_VENID && tdev->device == NEC_DEVID) { 1115 if (tdev->vendor == NEC_VENID && tdev->device == NEC_DEVID) {
1116 if (tdev->bus == s2io_pdev->bus->parent) 1116 if (tdev->bus == s2io_pdev->bus->parent) {
1117 pci_dev_put(tdev); 1117 pci_dev_put(tdev);
1118 return 1; 1118 return 1;
1119 }
1119 } 1120 }
1120 } 1121 }
1121 return 0; 1122 return 0;
@@ -1219,15 +1220,33 @@ static int init_tti(struct s2io_nic *nic, int link)
1219 TTI_DATA1_MEM_TX_URNG_B(0x10) | 1220 TTI_DATA1_MEM_TX_URNG_B(0x10) |
1220 TTI_DATA1_MEM_TX_URNG_C(0x30) | 1221 TTI_DATA1_MEM_TX_URNG_C(0x30) |
1221 TTI_DATA1_MEM_TX_TIMER_AC_EN; 1222 TTI_DATA1_MEM_TX_TIMER_AC_EN;
1222 1223 if (i == 0)
1223 if (use_continuous_tx_intrs && (link == LINK_UP)) 1224 if (use_continuous_tx_intrs && (link == LINK_UP))
1224 val64 |= TTI_DATA1_MEM_TX_TIMER_CI_EN; 1225 val64 |= TTI_DATA1_MEM_TX_TIMER_CI_EN;
1225 writeq(val64, &bar0->tti_data1_mem); 1226 writeq(val64, &bar0->tti_data1_mem);
1226 1227
1227 val64 = TTI_DATA2_MEM_TX_UFC_A(0x10) | 1228 if (nic->config.intr_type == MSI_X) {
1228 TTI_DATA2_MEM_TX_UFC_B(0x20) | 1229 val64 = TTI_DATA2_MEM_TX_UFC_A(0x10) |
1229 TTI_DATA2_MEM_TX_UFC_C(0x40) | 1230 TTI_DATA2_MEM_TX_UFC_B(0x100) |
1230 TTI_DATA2_MEM_TX_UFC_D(0x80); 1231 TTI_DATA2_MEM_TX_UFC_C(0x200) |
1232 TTI_DATA2_MEM_TX_UFC_D(0x300);
1233 } else {
1234 if ((nic->config.tx_steering_type ==
1235 TX_DEFAULT_STEERING) &&
1236 (config->tx_fifo_num > 1) &&
1237 (i >= nic->udp_fifo_idx) &&
1238 (i < (nic->udp_fifo_idx +
1239 nic->total_udp_fifos)))
1240 val64 = TTI_DATA2_MEM_TX_UFC_A(0x50) |
1241 TTI_DATA2_MEM_TX_UFC_B(0x80) |
1242 TTI_DATA2_MEM_TX_UFC_C(0x100) |
1243 TTI_DATA2_MEM_TX_UFC_D(0x120);
1244 else
1245 val64 = TTI_DATA2_MEM_TX_UFC_A(0x10) |
1246 TTI_DATA2_MEM_TX_UFC_B(0x20) |
1247 TTI_DATA2_MEM_TX_UFC_C(0x40) |
1248 TTI_DATA2_MEM_TX_UFC_D(0x80);
1249 }
1231 1250
1232 writeq(val64, &bar0->tti_data2_mem); 1251 writeq(val64, &bar0->tti_data2_mem);
1233 1252
@@ -2813,6 +2832,15 @@ static void free_rx_buffers(struct s2io_nic *sp)
2813 } 2832 }
2814} 2833}
2815 2834
2835static int s2io_chk_rx_buffers(struct ring_info *ring)
2836{
2837 if (fill_rx_buffers(ring) == -ENOMEM) {
2838 DBG_PRINT(INFO_DBG, "%s:Out of memory", ring->dev->name);
2839 DBG_PRINT(INFO_DBG, " in Rx Intr!!\n");
2840 }
2841 return 0;
2842}
2843
2816/** 2844/**
2817 * s2io_poll - Rx interrupt handler for NAPI support 2845 * s2io_poll - Rx interrupt handler for NAPI support
2818 * @napi : pointer to the napi structure. 2846 * @napi : pointer to the napi structure.
@@ -2826,57 +2854,72 @@ static void free_rx_buffers(struct s2io_nic *sp)
2826 * 0 on success and 1 if there are No Rx packets to be processed. 2854 * 0 on success and 1 if there are No Rx packets to be processed.
2827 */ 2855 */
2828 2856
2829static int s2io_poll(struct napi_struct *napi, int budget) 2857static int s2io_poll_msix(struct napi_struct *napi, int budget)
2830{ 2858{
2831 struct s2io_nic *nic = container_of(napi, struct s2io_nic, napi); 2859 struct ring_info *ring = container_of(napi, struct ring_info, napi);
2832 struct net_device *dev = nic->dev; 2860 struct net_device *dev = ring->dev;
2833 int pkt_cnt = 0, org_pkts_to_process;
2834 struct mac_info *mac_control;
2835 struct config_param *config; 2861 struct config_param *config;
2862 struct mac_info *mac_control;
2863 int pkts_processed = 0;
2864 u8 *addr = NULL, val8 = 0;
2865 struct s2io_nic *nic = dev->priv;
2836 struct XENA_dev_config __iomem *bar0 = nic->bar0; 2866 struct XENA_dev_config __iomem *bar0 = nic->bar0;
2837 int i; 2867 int budget_org = budget;
2838 2868
2839 mac_control = &nic->mac_control;
2840 config = &nic->config; 2869 config = &nic->config;
2870 mac_control = &nic->mac_control;
2841 2871
2842 nic->pkts_to_process = budget; 2872 if (unlikely(!is_s2io_card_up(nic)))
2843 org_pkts_to_process = nic->pkts_to_process; 2873 return 0;
2844 2874
2845 writeq(S2IO_MINUS_ONE, &bar0->rx_traffic_int); 2875 pkts_processed = rx_intr_handler(ring, budget);
2846 readl(&bar0->rx_traffic_int); 2876 s2io_chk_rx_buffers(ring);
2847 2877
2848 for (i = 0; i < config->rx_ring_num; i++) { 2878 if (pkts_processed < budget_org) {
2849 rx_intr_handler(&mac_control->rings[i]); 2879 netif_rx_complete(dev, napi);
2850 pkt_cnt = org_pkts_to_process - nic->pkts_to_process; 2880 /*Re Enable MSI-Rx Vector*/
2851 if (!nic->pkts_to_process) { 2881 addr = (u8 *)&bar0->xmsi_mask_reg;
2852 /* Quota for the current iteration has been met */ 2882 addr += 7 - ring->ring_no;
2853 goto no_rx; 2883 val8 = (ring->ring_no == 0) ? 0x3f : 0xbf;
2854 } 2884 writeb(val8, addr);
2885 val8 = readb(addr);
2855 } 2886 }
2887 return pkts_processed;
2888}
2889static int s2io_poll_inta(struct napi_struct *napi, int budget)
2890{
2891 struct s2io_nic *nic = container_of(napi, struct s2io_nic, napi);
2892 struct ring_info *ring;
2893 struct net_device *dev = nic->dev;
2894 struct config_param *config;
2895 struct mac_info *mac_control;
2896 int pkts_processed = 0;
2897 int ring_pkts_processed, i;
2898 struct XENA_dev_config __iomem *bar0 = nic->bar0;
2899 int budget_org = budget;
2856 2900
2857 netif_rx_complete(dev, napi); 2901 config = &nic->config;
2902 mac_control = &nic->mac_control;
2858 2903
2859 for (i = 0; i < config->rx_ring_num; i++) { 2904 if (unlikely(!is_s2io_card_up(nic)))
2860 if (fill_rx_buffers(&mac_control->rings[i]) == -ENOMEM) { 2905 return 0;
2861 DBG_PRINT(INFO_DBG, "%s:Out of memory", dev->name);
2862 DBG_PRINT(INFO_DBG, " in Rx Poll!!\n");
2863 break;
2864 }
2865 }
2866 /* Re enable the Rx interrupts. */
2867 writeq(0x0, &bar0->rx_traffic_mask);
2868 readl(&bar0->rx_traffic_mask);
2869 return pkt_cnt;
2870 2906
2871no_rx:
2872 for (i = 0; i < config->rx_ring_num; i++) { 2907 for (i = 0; i < config->rx_ring_num; i++) {
2873 if (fill_rx_buffers(&mac_control->rings[i]) == -ENOMEM) { 2908 ring = &mac_control->rings[i];
2874 DBG_PRINT(INFO_DBG, "%s:Out of memory", dev->name); 2909 ring_pkts_processed = rx_intr_handler(ring, budget);
2875 DBG_PRINT(INFO_DBG, " in Rx Poll!!\n"); 2910 s2io_chk_rx_buffers(ring);
2911 pkts_processed += ring_pkts_processed;
2912 budget -= ring_pkts_processed;
2913 if (budget <= 0)
2876 break; 2914 break;
2877 }
2878 } 2915 }
2879 return pkt_cnt; 2916 if (pkts_processed < budget_org) {
2917 netif_rx_complete(dev, napi);
2918 /* Re enable the Rx interrupts for the ring */
2919 writeq(0, &bar0->rx_traffic_mask);
2920 readl(&bar0->rx_traffic_mask);
2921 }
2922 return pkts_processed;
2880} 2923}
2881 2924
2882#ifdef CONFIG_NET_POLL_CONTROLLER 2925#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -2918,7 +2961,7 @@ static void s2io_netpoll(struct net_device *dev)
2918 2961
2919 /* check for received packet and indicate up to network */ 2962 /* check for received packet and indicate up to network */
2920 for (i = 0; i < config->rx_ring_num; i++) 2963 for (i = 0; i < config->rx_ring_num; i++)
2921 rx_intr_handler(&mac_control->rings[i]); 2964 rx_intr_handler(&mac_control->rings[i], 0);
2922 2965
2923 for (i = 0; i < config->rx_ring_num; i++) { 2966 for (i = 0; i < config->rx_ring_num; i++) {
2924 if (fill_rx_buffers(&mac_control->rings[i]) == -ENOMEM) { 2967 if (fill_rx_buffers(&mac_control->rings[i]) == -ENOMEM) {
@@ -2934,7 +2977,8 @@ static void s2io_netpoll(struct net_device *dev)
2934 2977
2935/** 2978/**
2936 * rx_intr_handler - Rx interrupt handler 2979 * rx_intr_handler - Rx interrupt handler
2937 * @nic: device private variable. 2980 * @ring_info: per ring structure.
2981 * @budget: budget for napi processing.
2938 * Description: 2982 * Description:
2939 * If the interrupt is because of a received frame or if the 2983 * If the interrupt is because of a received frame or if the
2940 * receive ring contains fresh as yet un-processed frames,this function is 2984 * receive ring contains fresh as yet un-processed frames,this function is
@@ -2942,15 +2986,15 @@ static void s2io_netpoll(struct net_device *dev)
2942 * stopped and sends the skb to the OSM's Rx handler and then increments 2986 * stopped and sends the skb to the OSM's Rx handler and then increments
2943 * the offset. 2987 * the offset.
2944 * Return Value: 2988 * Return Value:
2945 * NONE. 2989 * No. of napi packets processed.
2946 */ 2990 */
2947static void rx_intr_handler(struct ring_info *ring_data) 2991static int rx_intr_handler(struct ring_info *ring_data, int budget)
2948{ 2992{
2949 int get_block, put_block; 2993 int get_block, put_block;
2950 struct rx_curr_get_info get_info, put_info; 2994 struct rx_curr_get_info get_info, put_info;
2951 struct RxD_t *rxdp; 2995 struct RxD_t *rxdp;
2952 struct sk_buff *skb; 2996 struct sk_buff *skb;
2953 int pkt_cnt = 0; 2997 int pkt_cnt = 0, napi_pkts = 0;
2954 int i; 2998 int i;
2955 struct RxD1* rxdp1; 2999 struct RxD1* rxdp1;
2956 struct RxD3* rxdp3; 3000 struct RxD3* rxdp3;
@@ -2977,7 +3021,7 @@ static void rx_intr_handler(struct ring_info *ring_data)
2977 DBG_PRINT(ERR_DBG, "%s: The skb is ", 3021 DBG_PRINT(ERR_DBG, "%s: The skb is ",
2978 ring_data->dev->name); 3022 ring_data->dev->name);
2979 DBG_PRINT(ERR_DBG, "Null in Rx Intr\n"); 3023 DBG_PRINT(ERR_DBG, "Null in Rx Intr\n");
2980 return; 3024 return 0;
2981 } 3025 }
2982 if (ring_data->rxd_mode == RXD_MODE_1) { 3026 if (ring_data->rxd_mode == RXD_MODE_1) {
2983 rxdp1 = (struct RxD1*)rxdp; 3027 rxdp1 = (struct RxD1*)rxdp;
@@ -3014,9 +3058,10 @@ static void rx_intr_handler(struct ring_info *ring_data)
3014 rxdp = ring_data->rx_blocks[get_block].block_virt_addr; 3058 rxdp = ring_data->rx_blocks[get_block].block_virt_addr;
3015 } 3059 }
3016 3060
3017 if(ring_data->nic->config.napi){ 3061 if (ring_data->nic->config.napi) {
3018 ring_data->nic->pkts_to_process -= 1; 3062 budget--;
3019 if (!ring_data->nic->pkts_to_process) 3063 napi_pkts++;
3064 if (!budget)
3020 break; 3065 break;
3021 } 3066 }
3022 pkt_cnt++; 3067 pkt_cnt++;
@@ -3034,6 +3079,7 @@ static void rx_intr_handler(struct ring_info *ring_data)
3034 } 3079 }
3035 } 3080 }
3036 } 3081 }
3082 return(napi_pkts);
3037} 3083}
3038 3084
3039/** 3085/**
@@ -3730,14 +3776,19 @@ static void restore_xmsi_data(struct s2io_nic *nic)
3730{ 3776{
3731 struct XENA_dev_config __iomem *bar0 = nic->bar0; 3777 struct XENA_dev_config __iomem *bar0 = nic->bar0;
3732 u64 val64; 3778 u64 val64;
3733 int i; 3779 int i, msix_index;
3780
3781
3782 if (nic->device_type == XFRAME_I_DEVICE)
3783 return;
3734 3784
3735 for (i=0; i < MAX_REQUESTED_MSI_X; i++) { 3785 for (i=0; i < MAX_REQUESTED_MSI_X; i++) {
3786 msix_index = (i) ? ((i-1) * 8 + 1): 0;
3736 writeq(nic->msix_info[i].addr, &bar0->xmsi_address); 3787 writeq(nic->msix_info[i].addr, &bar0->xmsi_address);
3737 writeq(nic->msix_info[i].data, &bar0->xmsi_data); 3788 writeq(nic->msix_info[i].data, &bar0->xmsi_data);
3738 val64 = (s2BIT(7) | s2BIT(15) | vBIT(i, 26, 6)); 3789 val64 = (s2BIT(7) | s2BIT(15) | vBIT(msix_index, 26, 6));
3739 writeq(val64, &bar0->xmsi_access); 3790 writeq(val64, &bar0->xmsi_access);
3740 if (wait_for_msix_trans(nic, i)) { 3791 if (wait_for_msix_trans(nic, msix_index)) {
3741 DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__); 3792 DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__);
3742 continue; 3793 continue;
3743 } 3794 }
@@ -3748,13 +3799,17 @@ static void store_xmsi_data(struct s2io_nic *nic)
3748{ 3799{
3749 struct XENA_dev_config __iomem *bar0 = nic->bar0; 3800 struct XENA_dev_config __iomem *bar0 = nic->bar0;
3750 u64 val64, addr, data; 3801 u64 val64, addr, data;
3751 int i; 3802 int i, msix_index;
3803
3804 if (nic->device_type == XFRAME_I_DEVICE)
3805 return;
3752 3806
3753 /* Store and display */ 3807 /* Store and display */
3754 for (i=0; i < MAX_REQUESTED_MSI_X; i++) { 3808 for (i=0; i < MAX_REQUESTED_MSI_X; i++) {
3755 val64 = (s2BIT(15) | vBIT(i, 26, 6)); 3809 msix_index = (i) ? ((i-1) * 8 + 1): 0;
3810 val64 = (s2BIT(15) | vBIT(msix_index, 26, 6));
3756 writeq(val64, &bar0->xmsi_access); 3811 writeq(val64, &bar0->xmsi_access);
3757 if (wait_for_msix_trans(nic, i)) { 3812 if (wait_for_msix_trans(nic, msix_index)) {
3758 DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__); 3813 DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__);
3759 continue; 3814 continue;
3760 } 3815 }
@@ -3770,11 +3825,11 @@ static void store_xmsi_data(struct s2io_nic *nic)
3770static int s2io_enable_msi_x(struct s2io_nic *nic) 3825static int s2io_enable_msi_x(struct s2io_nic *nic)
3771{ 3826{
3772 struct XENA_dev_config __iomem *bar0 = nic->bar0; 3827 struct XENA_dev_config __iomem *bar0 = nic->bar0;
3773 u64 tx_mat, rx_mat; 3828 u64 rx_mat;
3774 u16 msi_control; /* Temp variable */ 3829 u16 msi_control; /* Temp variable */
3775 int ret, i, j, msix_indx = 1; 3830 int ret, i, j, msix_indx = 1;
3776 3831
3777 nic->entries = kcalloc(MAX_REQUESTED_MSI_X, sizeof(struct msix_entry), 3832 nic->entries = kmalloc(nic->num_entries * sizeof(struct msix_entry),
3778 GFP_KERNEL); 3833 GFP_KERNEL);
3779 if (!nic->entries) { 3834 if (!nic->entries) {
3780 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", \ 3835 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", \
@@ -3783,10 +3838,12 @@ static int s2io_enable_msi_x(struct s2io_nic *nic)
3783 return -ENOMEM; 3838 return -ENOMEM;
3784 } 3839 }
3785 nic->mac_control.stats_info->sw_stat.mem_allocated 3840 nic->mac_control.stats_info->sw_stat.mem_allocated
3786 += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); 3841 += (nic->num_entries * sizeof(struct msix_entry));
3842
3843 memset(nic->entries, 0, nic->num_entries * sizeof(struct msix_entry));
3787 3844
3788 nic->s2io_entries = 3845 nic->s2io_entries =
3789 kcalloc(MAX_REQUESTED_MSI_X, sizeof(struct s2io_msix_entry), 3846 kmalloc(nic->num_entries * sizeof(struct s2io_msix_entry),
3790 GFP_KERNEL); 3847 GFP_KERNEL);
3791 if (!nic->s2io_entries) { 3848 if (!nic->s2io_entries) {
3792 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", 3849 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n",
@@ -3794,60 +3851,52 @@ static int s2io_enable_msi_x(struct s2io_nic *nic)
3794 nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++; 3851 nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++;
3795 kfree(nic->entries); 3852 kfree(nic->entries);
3796 nic->mac_control.stats_info->sw_stat.mem_freed 3853 nic->mac_control.stats_info->sw_stat.mem_freed
3797 += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); 3854 += (nic->num_entries * sizeof(struct msix_entry));
3798 return -ENOMEM; 3855 return -ENOMEM;
3799 } 3856 }
3800 nic->mac_control.stats_info->sw_stat.mem_allocated 3857 nic->mac_control.stats_info->sw_stat.mem_allocated
3801 += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); 3858 += (nic->num_entries * sizeof(struct s2io_msix_entry));
3802 3859 memset(nic->s2io_entries, 0,
3803 for (i=0; i< MAX_REQUESTED_MSI_X; i++) { 3860 nic->num_entries * sizeof(struct s2io_msix_entry));
3804 nic->entries[i].entry = i; 3861
3805 nic->s2io_entries[i].entry = i; 3862 nic->entries[0].entry = 0;
3863 nic->s2io_entries[0].entry = 0;
3864 nic->s2io_entries[0].in_use = MSIX_FLG;
3865 nic->s2io_entries[0].type = MSIX_ALARM_TYPE;
3866 nic->s2io_entries[0].arg = &nic->mac_control.fifos;
3867
3868 for (i = 1; i < nic->num_entries; i++) {
3869 nic->entries[i].entry = ((i - 1) * 8) + 1;
3870 nic->s2io_entries[i].entry = ((i - 1) * 8) + 1;
3806 nic->s2io_entries[i].arg = NULL; 3871 nic->s2io_entries[i].arg = NULL;
3807 nic->s2io_entries[i].in_use = 0; 3872 nic->s2io_entries[i].in_use = 0;
3808 } 3873 }
3809 3874
3810 tx_mat = readq(&bar0->tx_mat0_n[0]);
3811 for (i=0; i<nic->config.tx_fifo_num; i++, msix_indx++) {
3812 tx_mat |= TX_MAT_SET(i, msix_indx);
3813 nic->s2io_entries[msix_indx].arg = &nic->mac_control.fifos[i];
3814 nic->s2io_entries[msix_indx].type = MSIX_FIFO_TYPE;
3815 nic->s2io_entries[msix_indx].in_use = MSIX_FLG;
3816 }
3817 writeq(tx_mat, &bar0->tx_mat0_n[0]);
3818
3819 rx_mat = readq(&bar0->rx_mat); 3875 rx_mat = readq(&bar0->rx_mat);
3820 for (j = 0; j < nic->config.rx_ring_num; j++, msix_indx++) { 3876 for (j = 0; j < nic->config.rx_ring_num; j++) {
3821 rx_mat |= RX_MAT_SET(j, msix_indx); 3877 rx_mat |= RX_MAT_SET(j, msix_indx);
3822 nic->s2io_entries[msix_indx].arg 3878 nic->s2io_entries[j+1].arg = &nic->mac_control.rings[j];
3823 = &nic->mac_control.rings[j]; 3879 nic->s2io_entries[j+1].type = MSIX_RING_TYPE;
3824 nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; 3880 nic->s2io_entries[j+1].in_use = MSIX_FLG;
3825 nic->s2io_entries[msix_indx].in_use = MSIX_FLG; 3881 msix_indx += 8;
3826 } 3882 }
3827 writeq(rx_mat, &bar0->rx_mat); 3883 writeq(rx_mat, &bar0->rx_mat);
3884 readq(&bar0->rx_mat);
3828 3885
3829 nic->avail_msix_vectors = 0; 3886 ret = pci_enable_msix(nic->pdev, nic->entries, nic->num_entries);
3830 ret = pci_enable_msix(nic->pdev, nic->entries, MAX_REQUESTED_MSI_X);
3831 /* We fail init if error or we get less vectors than min required */ 3887 /* We fail init if error or we get less vectors than min required */
3832 if (ret >= (nic->config.tx_fifo_num + nic->config.rx_ring_num + 1)) {
3833 nic->avail_msix_vectors = ret;
3834 ret = pci_enable_msix(nic->pdev, nic->entries, ret);
3835 }
3836 if (ret) { 3888 if (ret) {
3837 DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name); 3889 DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name);
3838 kfree(nic->entries); 3890 kfree(nic->entries);
3839 nic->mac_control.stats_info->sw_stat.mem_freed 3891 nic->mac_control.stats_info->sw_stat.mem_freed
3840 += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); 3892 += (nic->num_entries * sizeof(struct msix_entry));
3841 kfree(nic->s2io_entries); 3893 kfree(nic->s2io_entries);
3842 nic->mac_control.stats_info->sw_stat.mem_freed 3894 nic->mac_control.stats_info->sw_stat.mem_freed
3843 += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); 3895 += (nic->num_entries * sizeof(struct s2io_msix_entry));
3844 nic->entries = NULL; 3896 nic->entries = NULL;
3845 nic->s2io_entries = NULL; 3897 nic->s2io_entries = NULL;
3846 nic->avail_msix_vectors = 0;
3847 return -ENOMEM; 3898 return -ENOMEM;
3848 } 3899 }
3849 if (!nic->avail_msix_vectors)
3850 nic->avail_msix_vectors = MAX_REQUESTED_MSI_X;
3851 3900
3852 /* 3901 /*
3853 * To enable MSI-X, MSI also needs to be enabled, due to a bug 3902 * To enable MSI-X, MSI also needs to be enabled, due to a bug
@@ -3919,7 +3968,7 @@ static void remove_msix_isr(struct s2io_nic *sp)
3919 int i; 3968 int i;
3920 u16 msi_control; 3969 u16 msi_control;
3921 3970
3922 for (i = 0; i < MAX_REQUESTED_MSI_X; i++) { 3971 for (i = 0; i < sp->num_entries; i++) {
3923 if (sp->s2io_entries[i].in_use == 3972 if (sp->s2io_entries[i].in_use ==
3924 MSIX_REGISTERED_SUCCESS) { 3973 MSIX_REGISTERED_SUCCESS) {
3925 int vector = sp->entries[i].vector; 3974 int vector = sp->entries[i].vector;
@@ -3975,29 +4024,6 @@ static int s2io_open(struct net_device *dev)
3975 netif_carrier_off(dev); 4024 netif_carrier_off(dev);
3976 sp->last_link_state = 0; 4025 sp->last_link_state = 0;
3977 4026
3978 if (sp->config.intr_type == MSI_X) {
3979 int ret = s2io_enable_msi_x(sp);
3980
3981 if (!ret) {
3982 ret = s2io_test_msi(sp);
3983 /* rollback MSI-X, will re-enable during add_isr() */
3984 remove_msix_isr(sp);
3985 }
3986 if (ret) {
3987
3988 DBG_PRINT(ERR_DBG,
3989 "%s: MSI-X requested but failed to enable\n",
3990 dev->name);
3991 sp->config.intr_type = INTA;
3992 }
3993 }
3994
3995 /* NAPI doesn't work well with MSI(X) */
3996 if (sp->config.intr_type != INTA) {
3997 if(sp->config.napi)
3998 sp->config.napi = 0;
3999 }
4000
4001 /* Initialize H/W and enable interrupts */ 4027 /* Initialize H/W and enable interrupts */
4002 err = s2io_card_up(sp); 4028 err = s2io_card_up(sp);
4003 if (err) { 4029 if (err) {
@@ -4020,12 +4046,12 @@ hw_init_failed:
4020 if (sp->entries) { 4046 if (sp->entries) {
4021 kfree(sp->entries); 4047 kfree(sp->entries);
4022 sp->mac_control.stats_info->sw_stat.mem_freed 4048 sp->mac_control.stats_info->sw_stat.mem_freed
4023 += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); 4049 += (sp->num_entries * sizeof(struct msix_entry));
4024 } 4050 }
4025 if (sp->s2io_entries) { 4051 if (sp->s2io_entries) {
4026 kfree(sp->s2io_entries); 4052 kfree(sp->s2io_entries);
4027 sp->mac_control.stats_info->sw_stat.mem_freed 4053 sp->mac_control.stats_info->sw_stat.mem_freed
4028 += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); 4054 += (sp->num_entries * sizeof(struct s2io_msix_entry));
4029 } 4055 }
4030 } 4056 }
4031 return err; 4057 return err;
@@ -4327,40 +4353,64 @@ s2io_alarm_handle(unsigned long data)
4327 mod_timer(&sp->alarm_timer, jiffies + HZ / 2); 4353 mod_timer(&sp->alarm_timer, jiffies + HZ / 2);
4328} 4354}
4329 4355
4330static int s2io_chk_rx_buffers(struct ring_info *ring)
4331{
4332 if (fill_rx_buffers(ring) == -ENOMEM) {
4333 DBG_PRINT(INFO_DBG, "%s:Out of memory", ring->dev->name);
4334 DBG_PRINT(INFO_DBG, " in Rx Intr!!\n");
4335 }
4336 return 0;
4337}
4338
4339static irqreturn_t s2io_msix_ring_handle(int irq, void *dev_id) 4356static irqreturn_t s2io_msix_ring_handle(int irq, void *dev_id)
4340{ 4357{
4341 struct ring_info *ring = (struct ring_info *)dev_id; 4358 struct ring_info *ring = (struct ring_info *)dev_id;
4342 struct s2io_nic *sp = ring->nic; 4359 struct s2io_nic *sp = ring->nic;
4360 struct XENA_dev_config __iomem *bar0 = sp->bar0;
4361 struct net_device *dev = sp->dev;
4343 4362
4344 if (!is_s2io_card_up(sp)) 4363 if (unlikely(!is_s2io_card_up(sp)))
4345 return IRQ_HANDLED; 4364 return IRQ_HANDLED;
4346 4365
4347 rx_intr_handler(ring); 4366 if (sp->config.napi) {
4348 s2io_chk_rx_buffers(ring); 4367 u8 *addr = NULL, val8 = 0;
4368
4369 addr = (u8 *)&bar0->xmsi_mask_reg;
4370 addr += (7 - ring->ring_no);
4371 val8 = (ring->ring_no == 0) ? 0x7f : 0xff;
4372 writeb(val8, addr);
4373 val8 = readb(addr);
4374 netif_rx_schedule(dev, &ring->napi);
4375 } else {
4376 rx_intr_handler(ring, 0);
4377 s2io_chk_rx_buffers(ring);
4378 }
4349 4379
4350 return IRQ_HANDLED; 4380 return IRQ_HANDLED;
4351} 4381}
4352 4382
4353static irqreturn_t s2io_msix_fifo_handle(int irq, void *dev_id) 4383static irqreturn_t s2io_msix_fifo_handle(int irq, void *dev_id)
4354{ 4384{
4355 struct fifo_info *fifo = (struct fifo_info *)dev_id; 4385 int i;
4356 struct s2io_nic *sp = fifo->nic; 4386 struct fifo_info *fifos = (struct fifo_info *)dev_id;
4387 struct s2io_nic *sp = fifos->nic;
4388 struct XENA_dev_config __iomem *bar0 = sp->bar0;
4389 struct config_param *config = &sp->config;
4390 u64 reason;
4357 4391
4358 if (!is_s2io_card_up(sp)) 4392 if (unlikely(!is_s2io_card_up(sp)))
4393 return IRQ_NONE;
4394
4395 reason = readq(&bar0->general_int_status);
4396 if (unlikely(reason == S2IO_MINUS_ONE))
4397 /* Nothing much can be done. Get out */
4359 return IRQ_HANDLED; 4398 return IRQ_HANDLED;
4360 4399
4361 tx_intr_handler(fifo); 4400 writeq(S2IO_MINUS_ONE, &bar0->general_int_mask);
4401
4402 if (reason & GEN_INTR_TXTRAFFIC)
4403 writeq(S2IO_MINUS_ONE, &bar0->tx_traffic_int);
4404
4405 for (i = 0; i < config->tx_fifo_num; i++)
4406 tx_intr_handler(&fifos[i]);
4407
4408 writeq(sp->general_int_mask, &bar0->general_int_mask);
4409 readl(&bar0->general_int_status);
4410
4362 return IRQ_HANDLED; 4411 return IRQ_HANDLED;
4363} 4412}
4413
4364static void s2io_txpic_intr_handle(struct s2io_nic *sp) 4414static void s2io_txpic_intr_handle(struct s2io_nic *sp)
4365{ 4415{
4366 struct XENA_dev_config __iomem *bar0 = sp->bar0; 4416 struct XENA_dev_config __iomem *bar0 = sp->bar0;
@@ -4762,14 +4812,10 @@ static irqreturn_t s2io_isr(int irq, void *dev_id)
4762 4812
4763 if (config->napi) { 4813 if (config->napi) {
4764 if (reason & GEN_INTR_RXTRAFFIC) { 4814 if (reason & GEN_INTR_RXTRAFFIC) {
4765 if (likely(netif_rx_schedule_prep(dev, 4815 netif_rx_schedule(dev, &sp->napi);
4766 &sp->napi))) { 4816 writeq(S2IO_MINUS_ONE, &bar0->rx_traffic_mask);
4767 __netif_rx_schedule(dev, &sp->napi); 4817 writeq(S2IO_MINUS_ONE, &bar0->rx_traffic_int);
4768 writeq(S2IO_MINUS_ONE, 4818 readl(&bar0->rx_traffic_int);
4769 &bar0->rx_traffic_mask);
4770 } else
4771 writeq(S2IO_MINUS_ONE,
4772 &bar0->rx_traffic_int);
4773 } 4819 }
4774 } else { 4820 } else {
4775 /* 4821 /*
@@ -4781,7 +4827,7 @@ static irqreturn_t s2io_isr(int irq, void *dev_id)
4781 writeq(S2IO_MINUS_ONE, &bar0->rx_traffic_int); 4827 writeq(S2IO_MINUS_ONE, &bar0->rx_traffic_int);
4782 4828
4783 for (i = 0; i < config->rx_ring_num; i++) 4829 for (i = 0; i < config->rx_ring_num; i++)
4784 rx_intr_handler(&mac_control->rings[i]); 4830 rx_intr_handler(&mac_control->rings[i], 0);
4785 } 4831 }
4786 4832
4787 /* 4833 /*
@@ -6984,62 +7030,62 @@ static int s2io_add_isr(struct s2io_nic * sp)
6984 7030
6985 /* After proper initialization of H/W, register ISR */ 7031 /* After proper initialization of H/W, register ISR */
6986 if (sp->config.intr_type == MSI_X) { 7032 if (sp->config.intr_type == MSI_X) {
6987 int i, msix_tx_cnt=0,msix_rx_cnt=0; 7033 int i, msix_rx_cnt = 0;
6988 7034
6989 for (i=1; (sp->s2io_entries[i].in_use == MSIX_FLG); i++) { 7035 for (i = 0; i < sp->num_entries; i++) {
6990 if (sp->s2io_entries[i].type == MSIX_FIFO_TYPE) { 7036 if (sp->s2io_entries[i].in_use == MSIX_FLG) {
6991 sprintf(sp->desc[i], "%s:MSI-X-%d-TX", 7037 if (sp->s2io_entries[i].type ==
7038 MSIX_RING_TYPE) {
7039 sprintf(sp->desc[i], "%s:MSI-X-%d-RX",
7040 dev->name, i);
7041 err = request_irq(sp->entries[i].vector,
7042 s2io_msix_ring_handle, 0,
7043 sp->desc[i],
7044 sp->s2io_entries[i].arg);
7045 } else if (sp->s2io_entries[i].type ==
7046 MSIX_ALARM_TYPE) {
7047 sprintf(sp->desc[i], "%s:MSI-X-%d-TX",
6992 dev->name, i); 7048 dev->name, i);
6993 err = request_irq(sp->entries[i].vector, 7049 err = request_irq(sp->entries[i].vector,
6994 s2io_msix_fifo_handle, 0, sp->desc[i], 7050 s2io_msix_fifo_handle, 0,
6995 sp->s2io_entries[i].arg); 7051 sp->desc[i],
6996 /* If either data or addr is zero print it */ 7052 sp->s2io_entries[i].arg);
6997 if(!(sp->msix_info[i].addr && 7053
6998 sp->msix_info[i].data)) {
6999 DBG_PRINT(ERR_DBG, "%s @ Addr:0x%llx "
7000 "Data:0x%llx\n",sp->desc[i],
7001 (unsigned long long)
7002 sp->msix_info[i].addr,
7003 (unsigned long long)
7004 sp->msix_info[i].data);
7005 } else {
7006 msix_tx_cnt++;
7007 } 7054 }
7008 } else { 7055 /* if either data or addr is zero print it. */
7009 sprintf(sp->desc[i], "%s:MSI-X-%d-RX", 7056 if (!(sp->msix_info[i].addr &&
7010 dev->name, i);
7011 err = request_irq(sp->entries[i].vector,
7012 s2io_msix_ring_handle, 0, sp->desc[i],
7013 sp->s2io_entries[i].arg);
7014 /* If either data or addr is zero print it */
7015 if(!(sp->msix_info[i].addr &&
7016 sp->msix_info[i].data)) { 7057 sp->msix_info[i].data)) {
7017 DBG_PRINT(ERR_DBG, "%s @ Addr:0x%llx " 7058 DBG_PRINT(ERR_DBG,
7018 "Data:0x%llx\n",sp->desc[i], 7059 "%s @Addr:0x%llx Data:0x%llx\n",
7060 sp->desc[i],
7019 (unsigned long long) 7061 (unsigned long long)
7020 sp->msix_info[i].addr, 7062 sp->msix_info[i].addr,
7021 (unsigned long long) 7063 (unsigned long long)
7022 sp->msix_info[i].data); 7064 ntohl(sp->msix_info[i].data));
7023 } else { 7065 } else
7024 msix_rx_cnt++; 7066 msix_rx_cnt++;
7067 if (err) {
7068 remove_msix_isr(sp);
7069
7070 DBG_PRINT(ERR_DBG,
7071 "%s:MSI-X-%d registration "
7072 "failed\n", dev->name, i);
7073
7074 DBG_PRINT(ERR_DBG,
7075 "%s: Defaulting to INTA\n",
7076 dev->name);
7077 sp->config.intr_type = INTA;
7078 break;
7025 } 7079 }
7080 sp->s2io_entries[i].in_use =
7081 MSIX_REGISTERED_SUCCESS;
7026 } 7082 }
7027 if (err) {
7028 remove_msix_isr(sp);
7029 DBG_PRINT(ERR_DBG,"%s:MSI-X-%d registration "
7030 "failed\n", dev->name, i);
7031 DBG_PRINT(ERR_DBG, "%s: defaulting to INTA\n",
7032 dev->name);
7033 sp->config.intr_type = INTA;
7034 break;
7035 }
7036 sp->s2io_entries[i].in_use = MSIX_REGISTERED_SUCCESS;
7037 } 7083 }
7038 if (!err) { 7084 if (!err) {
7039 printk(KERN_INFO "MSI-X-TX %d entries enabled\n",
7040 msix_tx_cnt);
7041 printk(KERN_INFO "MSI-X-RX %d entries enabled\n", 7085 printk(KERN_INFO "MSI-X-RX %d entries enabled\n",
7042 msix_rx_cnt); 7086 --msix_rx_cnt);
7087 DBG_PRINT(INFO_DBG, "MSI-X-TX entries enabled"
7088 " through alarm vector\n");
7043 } 7089 }
7044 } 7090 }
7045 if (sp->config.intr_type == INTA) { 7091 if (sp->config.intr_type == INTA) {
@@ -7080,8 +7126,15 @@ static void do_s2io_card_down(struct s2io_nic * sp, int do_io)
7080 clear_bit(__S2IO_STATE_CARD_UP, &sp->state); 7126 clear_bit(__S2IO_STATE_CARD_UP, &sp->state);
7081 7127
7082 /* Disable napi */ 7128 /* Disable napi */
7083 if (config->napi) 7129 if (sp->config.napi) {
7084 napi_disable(&sp->napi); 7130 int off = 0;
7131 if (config->intr_type == MSI_X) {
7132 for (; off < sp->config.rx_ring_num; off++)
7133 napi_disable(&sp->mac_control.rings[off].napi);
7134 }
7135 else
7136 napi_disable(&sp->napi);
7137 }
7085 7138
7086 /* disable Tx and Rx traffic on the NIC */ 7139 /* disable Tx and Rx traffic on the NIC */
7087 if (do_io) 7140 if (do_io)
@@ -7173,8 +7226,15 @@ static int s2io_card_up(struct s2io_nic * sp)
7173 } 7226 }
7174 7227
7175 /* Initialise napi */ 7228 /* Initialise napi */
7176 if (config->napi) 7229 if (config->napi) {
7177 napi_enable(&sp->napi); 7230 int i;
7231 if (config->intr_type == MSI_X) {
7232 for (i = 0; i < sp->config.rx_ring_num; i++)
7233 napi_enable(&sp->mac_control.rings[i].napi);
7234 } else {
7235 napi_enable(&sp->napi);
7236 }
7237 }
7178 7238
7179 /* Maintain the state prior to the open */ 7239 /* Maintain the state prior to the open */
7180 if (sp->promisc_flg) 7240 if (sp->promisc_flg)
@@ -7217,7 +7277,7 @@ static int s2io_card_up(struct s2io_nic * sp)
7217 /* Enable select interrupts */ 7277 /* Enable select interrupts */
7218 en_dis_err_alarms(sp, ENA_ALL_INTRS, ENABLE_INTRS); 7278 en_dis_err_alarms(sp, ENA_ALL_INTRS, ENABLE_INTRS);
7219 if (sp->config.intr_type != INTA) 7279 if (sp->config.intr_type != INTA)
7220 en_dis_able_nic_intrs(sp, ENA_ALL_INTRS, DISABLE_INTRS); 7280 en_dis_able_nic_intrs(sp, TX_TRAFFIC_INTR, ENABLE_INTRS);
7221 else { 7281 else {
7222 interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR; 7282 interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR;
7223 interruptible |= TX_PIC_INTR; 7283 interruptible |= TX_PIC_INTR;
@@ -7615,9 +7675,6 @@ static int s2io_verify_parm(struct pci_dev *pdev, u8 *dev_intr_type,
7615 rx_ring_num = MAX_RX_RINGS; 7675 rx_ring_num = MAX_RX_RINGS;
7616 } 7676 }
7617 7677
7618 if (*dev_intr_type != INTA)
7619 napi = 0;
7620
7621 if ((*dev_intr_type != INTA) && (*dev_intr_type != MSI_X)) { 7678 if ((*dev_intr_type != INTA) && (*dev_intr_type != MSI_X)) {
7622 DBG_PRINT(ERR_DBG, "s2io: Wrong intr_type requested. " 7679 DBG_PRINT(ERR_DBG, "s2io: Wrong intr_type requested. "
7623 "Defaulting to INTA\n"); 7680 "Defaulting to INTA\n");
@@ -7918,8 +7975,6 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
7918 * will use eth_mac_addr() for dev->set_mac_address 7975 * will use eth_mac_addr() for dev->set_mac_address
7919 * mac address will be set every time dev->open() is called 7976 * mac address will be set every time dev->open() is called
7920 */ 7977 */
7921 netif_napi_add(dev, &sp->napi, s2io_poll, 32);
7922
7923#ifdef CONFIG_NET_POLL_CONTROLLER 7978#ifdef CONFIG_NET_POLL_CONTROLLER
7924 dev->poll_controller = s2io_netpoll; 7979 dev->poll_controller = s2io_netpoll;
7925#endif 7980#endif
@@ -7963,6 +8018,32 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
7963 } 8018 }
7964 } 8019 }
7965 8020
8021 if (sp->config.intr_type == MSI_X) {
8022 sp->num_entries = config->rx_ring_num + 1;
8023 ret = s2io_enable_msi_x(sp);
8024
8025 if (!ret) {
8026 ret = s2io_test_msi(sp);
8027 /* rollback MSI-X, will re-enable during add_isr() */
8028 remove_msix_isr(sp);
8029 }
8030 if (ret) {
8031
8032 DBG_PRINT(ERR_DBG,
8033 "%s: MSI-X requested but failed to enable\n",
8034 dev->name);
8035 sp->config.intr_type = INTA;
8036 }
8037 }
8038
8039 if (config->intr_type == MSI_X) {
8040 for (i = 0; i < config->rx_ring_num ; i++)
8041 netif_napi_add(dev, &mac_control->rings[i].napi,
8042 s2io_poll_msix, 64);
8043 } else {
8044 netif_napi_add(dev, &sp->napi, s2io_poll_inta, 64);
8045 }
8046
7966 /* Not needed for Herc */ 8047 /* Not needed for Herc */
7967 if (sp->device_type & XFRAME_I_DEVICE) { 8048 if (sp->device_type & XFRAME_I_DEVICE) {
7968 /* 8049 /*
@@ -8013,6 +8094,11 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
8013 /* store mac addresses from CAM to s2io_nic structure */ 8094 /* store mac addresses from CAM to s2io_nic structure */
8014 do_s2io_store_unicast_mc(sp); 8095 do_s2io_store_unicast_mc(sp);
8015 8096
8097 /* Configure MSIX vector for number of rings configured plus one */
8098 if ((sp->device_type == XFRAME_II_DEVICE) &&
8099 (config->intr_type == MSI_X))
8100 sp->num_entries = config->rx_ring_num + 1;
8101
8016 /* Store the values of the MSIX table in the s2io_nic structure */ 8102 /* Store the values of the MSIX table in the s2io_nic structure */
8017 store_xmsi_data(sp); 8103 store_xmsi_data(sp);
8018 /* reset Nic and bring it to known state */ 8104 /* reset Nic and bring it to known state */
@@ -8078,8 +8164,14 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
8078 break; 8164 break;
8079 } 8165 }
8080 8166
8081 if (napi) 8167 switch (sp->config.napi) {
8168 case 0:
8169 DBG_PRINT(ERR_DBG, "%s: NAPI disabled\n", dev->name);
8170 break;
8171 case 1:
8082 DBG_PRINT(ERR_DBG, "%s: NAPI enabled\n", dev->name); 8172 DBG_PRINT(ERR_DBG, "%s: NAPI enabled\n", dev->name);
8173 break;
8174 }
8083 8175
8084 DBG_PRINT(ERR_DBG, "%s: Using %d Tx fifo(s)\n", dev->name, 8176 DBG_PRINT(ERR_DBG, "%s: Using %d Tx fifo(s)\n", dev->name,
8085 sp->config.tx_fifo_num); 8177 sp->config.tx_fifo_num);