Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

S2io: Added napi support when MSIX is enabled.

- Added napi support when MSIX is enabled.
- Moved test_msi function from s2io_open to probe function.

Signed-off-by: Sreenivasa Honnur <sreenivasa.honnur@neterion.com>
Signed-off-by: Ramkrishna Vepa <ram.vepa@neterion.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>

authored by

Sreenivasa Honnur and committed by
Jeff Garzik
f61e0a35 ac731ab6

+207 -143
+1 -1
drivers/net/s2io-regs.h
··· 250 250 u64 tx_mat0_n[0x8]; 251 251 #define TX_MAT_SET(fifo, msi) vBIT(msi, (8 * fifo), 8) 252 252 253 - u8 unused_1[0x8]; 253 + u64 xmsi_mask_reg; 254 254 u64 stat_byte_cnt; 255 255 #define STAT_BC(n) vBIT(n,4,12) 256 256
+194 -137
drivers/net/s2io.c
··· 2832 2832 } 2833 2833 } 2834 2834 2835 + static 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 + 2835 2844 /** 2836 2845 * s2io_poll - Rx interrupt handler for NAPI support 2837 2846 * @napi : pointer to the napi structure. ··· 2854 2845 * 0 on success and 1 if there are No Rx packets to be processed. 2855 2846 */ 2856 2847 2857 - static int s2io_poll(struct napi_struct *napi, int budget) 2848 + static int s2io_poll_msix(struct napi_struct *napi, int budget) 2849 + { 2850 + struct ring_info *ring = container_of(napi, struct ring_info, napi); 2851 + struct net_device *dev = ring->dev; 2852 + struct config_param *config; 2853 + struct mac_info *mac_control; 2854 + int pkts_processed = 0; 2855 + u8 *addr = NULL, val8 = 0; 2856 + struct s2io_nic *nic = dev->priv; 2857 + struct XENA_dev_config __iomem *bar0 = nic->bar0; 2858 + int budget_org = budget; 2859 + 2860 + config = &nic->config; 2861 + mac_control = &nic->mac_control; 2862 + 2863 + if (unlikely(!is_s2io_card_up(nic))) 2864 + return 0; 2865 + 2866 + pkts_processed = rx_intr_handler(ring, budget); 2867 + s2io_chk_rx_buffers(ring); 2868 + 2869 + if (pkts_processed < budget_org) { 2870 + netif_rx_complete(dev, napi); 2871 + /*Re Enable MSI-Rx Vector*/ 2872 + addr = (u8 *)&bar0->xmsi_mask_reg; 2873 + addr += 7 - ring->ring_no; 2874 + val8 = (ring->ring_no == 0) ? 0x3f : 0xbf; 2875 + writeb(val8, addr); 2876 + val8 = readb(addr); 2877 + } 2878 + return pkts_processed; 2879 + } 2880 + static int s2io_poll_inta(struct napi_struct *napi, int budget) 2858 2881 { 2859 2882 struct s2io_nic *nic = container_of(napi, struct s2io_nic, napi); 2883 + struct ring_info *ring; 2860 2884 struct net_device *dev = nic->dev; 2861 - int pkt_cnt = 0, org_pkts_to_process; 2862 - struct mac_info *mac_control; 2863 2885 struct config_param *config; 2886 + struct mac_info *mac_control; 2887 + int pkts_processed = 0; 2888 + int ring_pkts_processed, i; 2864 2889 struct XENA_dev_config __iomem *bar0 = nic->bar0; 2865 - int i; 2890 + int budget_org = budget; 2866 2891 2867 - mac_control = &nic->mac_control; 2868 2892 config = &nic->config; 2893 + mac_control = &nic->mac_control; 2869 2894 2870 - nic->pkts_to_process = budget; 2871 - org_pkts_to_process = nic->pkts_to_process; 2872 - 2873 - writeq(S2IO_MINUS_ONE, &bar0->rx_traffic_int); 2874 - readl(&bar0->rx_traffic_int); 2895 + if (unlikely(!is_s2io_card_up(nic))) 2896 + return 0; 2875 2897 2876 2898 for (i = 0; i < config->rx_ring_num; i++) { 2877 - rx_intr_handler(&mac_control->rings[i]); 2878 - pkt_cnt = org_pkts_to_process - nic->pkts_to_process; 2879 - if (!nic->pkts_to_process) { 2880 - /* Quota for the current iteration has been met */ 2881 - goto no_rx; 2882 - } 2883 - } 2884 - 2885 - netif_rx_complete(dev, napi); 2886 - 2887 - for (i = 0; i < config->rx_ring_num; i++) { 2888 - if (fill_rx_buffers(&mac_control->rings[i]) == -ENOMEM) { 2889 - DBG_PRINT(INFO_DBG, "%s:Out of memory", dev->name); 2890 - DBG_PRINT(INFO_DBG, " in Rx Poll!!\n"); 2899 + ring = &mac_control->rings[i]; 2900 + ring_pkts_processed = rx_intr_handler(ring, budget); 2901 + s2io_chk_rx_buffers(ring); 2902 + pkts_processed += ring_pkts_processed; 2903 + budget -= ring_pkts_processed; 2904 + if (budget <= 0) 2891 2905 break; 2892 - } 2893 2906 } 2894 - /* Re enable the Rx interrupts. */ 2895 - writeq(0x0, &bar0->rx_traffic_mask); 2896 - readl(&bar0->rx_traffic_mask); 2897 - return pkt_cnt; 2898 - 2899 - no_rx: 2900 - for (i = 0; i < config->rx_ring_num; i++) { 2901 - if (fill_rx_buffers(&mac_control->rings[i]) == -ENOMEM) { 2902 - DBG_PRINT(INFO_DBG, "%s:Out of memory", dev->name); 2903 - DBG_PRINT(INFO_DBG, " in Rx Poll!!\n"); 2904 - break; 2905 - } 2907 + if (pkts_processed < budget_org) { 2908 + netif_rx_complete(dev, napi); 2909 + /* Re enable the Rx interrupts for the ring */ 2910 + writeq(0, &bar0->rx_traffic_mask); 2911 + readl(&bar0->rx_traffic_mask); 2906 2912 } 2907 - return pkt_cnt; 2913 + return pkts_processed; 2908 2914 } 2909 2915 2910 2916 #ifdef CONFIG_NET_POLL_CONTROLLER ··· 2961 2937 2962 2938 /* check for received packet and indicate up to network */ 2963 2939 for (i = 0; i < config->rx_ring_num; i++) 2964 - rx_intr_handler(&mac_control->rings[i]); 2940 + rx_intr_handler(&mac_control->rings[i], 0); 2965 2941 2966 2942 for (i = 0; i < config->rx_ring_num; i++) { 2967 2943 if (fill_rx_buffers(&mac_control->rings[i]) == -ENOMEM) { ··· 2977 2953 2978 2954 /** 2979 2955 * rx_intr_handler - Rx interrupt handler 2980 - * @nic: device private variable. 2956 + * @ring_info: per ring structure. 2957 + * @budget: budget for napi processing. 2981 2958 * Description: 2982 2959 * If the interrupt is because of a received frame or if the 2983 2960 * receive ring contains fresh as yet un-processed frames,this function is ··· 2986 2961 * stopped and sends the skb to the OSM's Rx handler and then increments 2987 2962 * the offset. 2988 2963 * Return Value: 2989 - * NONE. 2964 + * No. of napi packets processed. 2990 2965 */ 2991 - static void rx_intr_handler(struct ring_info *ring_data) 2966 + static int rx_intr_handler(struct ring_info *ring_data, int budget) 2992 2967 { 2993 2968 int get_block, put_block; 2994 2969 struct rx_curr_get_info get_info, put_info; 2995 2970 struct RxD_t *rxdp; 2996 2971 struct sk_buff *skb; 2997 - int pkt_cnt = 0; 2972 + int pkt_cnt = 0, napi_pkts = 0; 2998 2973 int i; 2999 2974 struct RxD1* rxdp1; 3000 2975 struct RxD3* rxdp3; ··· 3021 2996 DBG_PRINT(ERR_DBG, "%s: The skb is ", 3022 2997 ring_data->dev->name); 3023 2998 DBG_PRINT(ERR_DBG, "Null in Rx Intr\n"); 3024 - return; 2999 + return 0; 3025 3000 } 3026 3001 if (ring_data->rxd_mode == RXD_MODE_1) { 3027 3002 rxdp1 = (struct RxD1*)rxdp; ··· 3058 3033 rxdp = ring_data->rx_blocks[get_block].block_virt_addr; 3059 3034 } 3060 3035 3061 - if(ring_data->nic->config.napi){ 3062 - ring_data->nic->pkts_to_process -= 1; 3063 - if (!ring_data->nic->pkts_to_process) 3036 + if (ring_data->nic->config.napi) { 3037 + budget--; 3038 + napi_pkts++; 3039 + if (!budget) 3064 3040 break; 3065 3041 } 3066 3042 pkt_cnt++; ··· 3079 3053 } 3080 3054 } 3081 3055 } 3056 + return(napi_pkts); 3082 3057 } 3083 3058 3084 3059 /** ··· 3776 3749 { 3777 3750 struct XENA_dev_config __iomem *bar0 = nic->bar0; 3778 3751 u64 val64; 3779 - int i; 3752 + int i, msix_index; 3753 + 3754 + 3755 + if (nic->device_type == XFRAME_I_DEVICE) 3756 + return; 3780 3757 3781 3758 for (i=0; i < MAX_REQUESTED_MSI_X; i++) { 3759 + msix_index = (i) ? ((i-1) * 8 + 1): 0; 3782 3760 writeq(nic->msix_info[i].addr, &bar0->xmsi_address); 3783 3761 writeq(nic->msix_info[i].data, &bar0->xmsi_data); 3784 - val64 = (s2BIT(7) | s2BIT(15) | vBIT(i, 26, 6)); 3762 + val64 = (s2BIT(7) | s2BIT(15) | vBIT(msix_index, 26, 6)); 3785 3763 writeq(val64, &bar0->xmsi_access); 3786 - if (wait_for_msix_trans(nic, i)) { 3764 + if (wait_for_msix_trans(nic, msix_index)) { 3787 3765 DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__); 3788 3766 continue; 3789 3767 } ··· 3799 3767 { 3800 3768 struct XENA_dev_config __iomem *bar0 = nic->bar0; 3801 3769 u64 val64, addr, data; 3802 - int i; 3770 + int i, msix_index; 3771 + 3772 + if (nic->device_type == XFRAME_I_DEVICE) 3773 + return; 3803 3774 3804 3775 /* Store and display */ 3805 3776 for (i=0; i < MAX_REQUESTED_MSI_X; i++) { 3806 - val64 = (s2BIT(15) | vBIT(i, 26, 6)); 3777 + msix_index = (i) ? ((i-1) * 8 + 1): 0; 3778 + val64 = (s2BIT(15) | vBIT(msix_index, 26, 6)); 3807 3779 writeq(val64, &bar0->xmsi_access); 3808 - if (wait_for_msix_trans(nic, i)) { 3780 + if (wait_for_msix_trans(nic, msix_index)) { 3809 3781 DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__); 3810 3782 continue; 3811 3783 } ··· 3829 3793 u16 msi_control; /* Temp variable */ 3830 3794 int ret, i, j, msix_indx = 1; 3831 3795 3832 - nic->entries = kcalloc(MAX_REQUESTED_MSI_X, sizeof(struct msix_entry), 3796 + nic->entries = kmalloc(nic->num_entries * sizeof(struct msix_entry), 3833 3797 GFP_KERNEL); 3834 3798 if (!nic->entries) { 3835 3799 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", \ ··· 3838 3802 return -ENOMEM; 3839 3803 } 3840 3804 nic->mac_control.stats_info->sw_stat.mem_allocated 3841 - += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); 3805 + += (nic->num_entries * sizeof(struct msix_entry)); 3806 + 3807 + memset(nic->entries, 0, nic->num_entries * sizeof(struct msix_entry)); 3842 3808 3843 3809 nic->s2io_entries = 3844 - kcalloc(MAX_REQUESTED_MSI_X, sizeof(struct s2io_msix_entry), 3810 + kmalloc(nic->num_entries * sizeof(struct s2io_msix_entry), 3845 3811 GFP_KERNEL); 3846 3812 if (!nic->s2io_entries) { 3847 3813 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", ··· 3851 3813 nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++; 3852 3814 kfree(nic->entries); 3853 3815 nic->mac_control.stats_info->sw_stat.mem_freed 3854 - += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); 3816 + += (nic->num_entries * sizeof(struct msix_entry)); 3855 3817 return -ENOMEM; 3856 3818 } 3857 3819 nic->mac_control.stats_info->sw_stat.mem_allocated 3858 - += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); 3820 + += (nic->num_entries * sizeof(struct s2io_msix_entry)); 3821 + memset(nic->s2io_entries, 0, 3822 + nic->num_entries * sizeof(struct s2io_msix_entry)); 3859 3823 3860 3824 nic->entries[0].entry = 0; 3861 3825 nic->s2io_entries[0].entry = 0; ··· 3865 3825 nic->s2io_entries[0].type = MSIX_ALARM_TYPE; 3866 3826 nic->s2io_entries[0].arg = &nic->mac_control.fifos; 3867 3827 3868 - for (i = 1; i < MAX_REQUESTED_MSI_X; i++) { 3869 - nic->entries[i].entry = i; 3870 - nic->s2io_entries[i].entry = i; 3828 + for (i = 1; i < nic->num_entries; i++) { 3829 + nic->entries[i].entry = ((i - 1) * 8) + 1; 3830 + nic->s2io_entries[i].entry = ((i - 1) * 8) + 1; 3871 3831 nic->s2io_entries[i].arg = NULL; 3872 3832 nic->s2io_entries[i].in_use = 0; 3873 3833 } 3874 3834 3875 3835 rx_mat = readq(&bar0->rx_mat); 3876 - for (j = 0; j < nic->config.rx_ring_num; j++, msix_indx++) { 3836 + for (j = 0; j < nic->config.rx_ring_num; j++) { 3877 3837 rx_mat |= RX_MAT_SET(j, msix_indx); 3878 - nic->s2io_entries[msix_indx].arg 3879 - = &nic->mac_control.rings[j]; 3880 - nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; 3881 - nic->s2io_entries[msix_indx].in_use = MSIX_FLG; 3838 + nic->s2io_entries[j+1].arg = &nic->mac_control.rings[j]; 3839 + nic->s2io_entries[j+1].type = MSIX_RING_TYPE; 3840 + nic->s2io_entries[j+1].in_use = MSIX_FLG; 3841 + msix_indx += 8; 3882 3842 } 3883 3843 writeq(rx_mat, &bar0->rx_mat); 3844 + readq(&bar0->rx_mat); 3884 3845 3885 - nic->avail_msix_vectors = 0; 3886 - ret = pci_enable_msix(nic->pdev, nic->entries, MAX_REQUESTED_MSI_X); 3846 + ret = pci_enable_msix(nic->pdev, nic->entries, nic->num_entries); 3887 3847 /* We fail init if error or we get less vectors than min required */ 3888 - if (ret >= (nic->config.tx_fifo_num + nic->config.rx_ring_num + 1)) { 3889 - nic->avail_msix_vectors = ret; 3890 - ret = pci_enable_msix(nic->pdev, nic->entries, ret); 3891 - } 3892 3848 if (ret) { 3893 3849 DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name); 3894 3850 kfree(nic->entries); 3895 3851 nic->mac_control.stats_info->sw_stat.mem_freed 3896 - += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); 3852 + += (nic->num_entries * sizeof(struct msix_entry)); 3897 3853 kfree(nic->s2io_entries); 3898 3854 nic->mac_control.stats_info->sw_stat.mem_freed 3899 - += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); 3855 + += (nic->num_entries * sizeof(struct s2io_msix_entry)); 3900 3856 nic->entries = NULL; 3901 3857 nic->s2io_entries = NULL; 3902 - nic->avail_msix_vectors = 0; 3903 3858 return -ENOMEM; 3904 3859 } 3905 - if (!nic->avail_msix_vectors) 3906 - nic->avail_msix_vectors = MAX_REQUESTED_MSI_X; 3907 3860 3908 3861 /* 3909 3862 * To enable MSI-X, MSI also needs to be enabled, due to a bug ··· 3968 3935 int i; 3969 3936 u16 msi_control; 3970 3937 3971 - for (i = 0; i < MAX_REQUESTED_MSI_X; i++) { 3938 + for (i = 0; i < sp->num_entries; i++) { 3972 3939 if (sp->s2io_entries[i].in_use == 3973 3940 MSIX_REGISTERED_SUCCESS) { 3974 3941 int vector = sp->entries[i].vector; ··· 4024 3991 netif_carrier_off(dev); 4025 3992 sp->last_link_state = 0; 4026 3993 4027 - if (sp->config.intr_type == MSI_X) { 4028 - int ret = s2io_enable_msi_x(sp); 4029 - 4030 - if (!ret) { 4031 - ret = s2io_test_msi(sp); 4032 - /* rollback MSI-X, will re-enable during add_isr() */ 4033 - remove_msix_isr(sp); 4034 - } 4035 - if (ret) { 4036 - 4037 - DBG_PRINT(ERR_DBG, 4038 - "%s: MSI-X requested but failed to enable\n", 4039 - dev->name); 4040 - sp->config.intr_type = INTA; 4041 - } 4042 - } 4043 - 4044 - /* NAPI doesn't work well with MSI(X) */ 4045 - if (sp->config.intr_type != INTA) { 4046 - if(sp->config.napi) 4047 - sp->config.napi = 0; 4048 - } 4049 - 4050 3994 /* Initialize H/W and enable interrupts */ 4051 3995 err = s2io_card_up(sp); 4052 3996 if (err) { ··· 4046 4036 if (sp->entries) { 4047 4037 kfree(sp->entries); 4048 4038 sp->mac_control.stats_info->sw_stat.mem_freed 4049 - += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); 4039 + += (sp->num_entries * sizeof(struct msix_entry)); 4050 4040 } 4051 4041 if (sp->s2io_entries) { 4052 4042 kfree(sp->s2io_entries); 4053 4043 sp->mac_control.stats_info->sw_stat.mem_freed 4054 - += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); 4044 + += (sp->num_entries * sizeof(struct s2io_msix_entry)); 4055 4045 } 4056 4046 } 4057 4047 return err; ··· 4353 4343 mod_timer(&sp->alarm_timer, jiffies + HZ / 2); 4354 4344 } 4355 4345 4356 - static int s2io_chk_rx_buffers(struct ring_info *ring) 4357 - { 4358 - if (fill_rx_buffers(ring) == -ENOMEM) { 4359 - DBG_PRINT(INFO_DBG, "%s:Out of memory", ring->dev->name); 4360 - DBG_PRINT(INFO_DBG, " in Rx Intr!!\n"); 4361 - } 4362 - return 0; 4363 - } 4364 - 4365 4346 static irqreturn_t s2io_msix_ring_handle(int irq, void *dev_id) 4366 4347 { 4367 4348 struct ring_info *ring = (struct ring_info *)dev_id; 4368 4349 struct s2io_nic *sp = ring->nic; 4350 + struct XENA_dev_config __iomem *bar0 = sp->bar0; 4351 + struct net_device *dev = sp->dev; 4369 4352 4370 - if (!is_s2io_card_up(sp)) 4353 + if (unlikely(!is_s2io_card_up(sp))) 4371 4354 return IRQ_HANDLED; 4372 4355 4373 - rx_intr_handler(ring); 4374 - s2io_chk_rx_buffers(ring); 4356 + if (sp->config.napi) { 4357 + u8 *addr = NULL, val8 = 0; 4358 + 4359 + addr = (u8 *)&bar0->xmsi_mask_reg; 4360 + addr += (7 - ring->ring_no); 4361 + val8 = (ring->ring_no == 0) ? 0x7f : 0xff; 4362 + writeb(val8, addr); 4363 + val8 = readb(addr); 4364 + netif_rx_schedule(dev, &ring->napi); 4365 + } else { 4366 + rx_intr_handler(ring, 0); 4367 + s2io_chk_rx_buffers(ring); 4368 + } 4375 4369 4376 4370 return IRQ_HANDLED; 4377 4371 } ··· 4812 4798 4813 4799 if (config->napi) { 4814 4800 if (reason & GEN_INTR_RXTRAFFIC) { 4815 - if (likely(netif_rx_schedule_prep(dev, 4816 - &sp->napi))) { 4817 - __netif_rx_schedule(dev, &sp->napi); 4818 - writeq(S2IO_MINUS_ONE, 4819 - &bar0->rx_traffic_mask); 4820 - } else 4821 - writeq(S2IO_MINUS_ONE, 4822 - &bar0->rx_traffic_int); 4801 + netif_rx_schedule(dev, &sp->napi); 4802 + writeq(S2IO_MINUS_ONE, &bar0->rx_traffic_mask); 4803 + writeq(S2IO_MINUS_ONE, &bar0->rx_traffic_int); 4804 + readl(&bar0->rx_traffic_int); 4823 4805 } 4824 4806 } else { 4825 4807 /* ··· 4827 4817 writeq(S2IO_MINUS_ONE, &bar0->rx_traffic_int); 4828 4818 4829 4819 for (i = 0; i < config->rx_ring_num; i++) 4830 - rx_intr_handler(&mac_control->rings[i]); 4820 + rx_intr_handler(&mac_control->rings[i], 0); 4831 4821 } 4832 4822 4833 4823 /* ··· 7032 7022 if (sp->config.intr_type == MSI_X) { 7033 7023 int i, msix_rx_cnt = 0; 7034 7024 7035 - for (i = 0; (sp->s2io_entries[i].in_use == MSIX_FLG); i++) { 7036 - if (sp->s2io_entries[i].type == 7025 + for (i = 0; i < sp->num_entries; i++) { 7026 + if (sp->s2io_entries[i].in_use == MSIX_FLG) { 7027 + if (sp->s2io_entries[i].type == 7037 7028 MSIX_RING_TYPE) { 7038 7029 sprintf(sp->desc[i], "%s:MSI-X-%d-RX", 7039 7030 dev->name, i); ··· 7079 7068 } 7080 7069 sp->s2io_entries[i].in_use = 7081 7070 MSIX_REGISTERED_SUCCESS; 7082 - 7071 + } 7083 7072 } 7084 7073 if (!err) { 7085 7074 printk(KERN_INFO "MSI-X-RX %d entries enabled\n", ··· 7126 7115 clear_bit(__S2IO_STATE_CARD_UP, &sp->state); 7127 7116 7128 7117 /* Disable napi */ 7129 - if (config->napi) 7130 - napi_disable(&sp->napi); 7118 + if (sp->config.napi) { 7119 + int off = 0; 7120 + if (config->intr_type == MSI_X) { 7121 + for (; off < sp->config.rx_ring_num; off++) 7122 + napi_disable(&sp->mac_control.rings[off].napi); 7123 + } 7124 + else 7125 + napi_disable(&sp->napi); 7126 + } 7131 7127 7132 7128 /* disable Tx and Rx traffic on the NIC */ 7133 7129 if (do_io) ··· 7226 7208 } 7227 7209 7228 7210 /* Initialise napi */ 7229 - if (config->napi) 7230 - napi_enable(&sp->napi); 7211 + if (config->napi) { 7212 + int i; 7213 + if (config->intr_type == MSI_X) { 7214 + for (i = 0; i < sp->config.rx_ring_num; i++) 7215 + napi_enable(&sp->mac_control.rings[i].napi); 7216 + } else { 7217 + napi_enable(&sp->napi); 7218 + } 7219 + } 7231 7220 7232 7221 /* Maintain the state prior to the open */ 7233 7222 if (sp->promisc_flg) ··· 7675 7650 rx_ring_num = MAX_RX_RINGS; 7676 7651 } 7677 7652 7678 - if (*dev_intr_type != INTA) 7679 - napi = 0; 7680 - 7681 7653 if ((*dev_intr_type != INTA) && (*dev_intr_type != MSI_X)) { 7682 7654 DBG_PRINT(ERR_DBG, "s2io: Wrong intr_type requested. " 7683 7655 "Defaulting to INTA\n"); ··· 7975 7953 * will use eth_mac_addr() for dev->set_mac_address 7976 7954 * mac address will be set every time dev->open() is called 7977 7955 */ 7978 - netif_napi_add(dev, &sp->napi, s2io_poll, 32); 7979 - 7980 7956 #ifdef CONFIG_NET_POLL_CONTROLLER 7981 7957 dev->poll_controller = s2io_netpoll; 7982 7958 #endif ··· 8016 7996 ret = -EBADSLT; 8017 7997 goto set_swap_failed; 8018 7998 } 7999 + } 8000 + 8001 + if (sp->config.intr_type == MSI_X) { 8002 + sp->num_entries = config->rx_ring_num + 1; 8003 + ret = s2io_enable_msi_x(sp); 8004 + 8005 + if (!ret) { 8006 + ret = s2io_test_msi(sp); 8007 + /* rollback MSI-X, will re-enable during add_isr() */ 8008 + remove_msix_isr(sp); 8009 + } 8010 + if (ret) { 8011 + 8012 + DBG_PRINT(ERR_DBG, 8013 + "%s: MSI-X requested but failed to enable\n", 8014 + dev->name); 8015 + sp->config.intr_type = INTA; 8016 + } 8017 + } 8018 + 8019 + if (config->intr_type == MSI_X) { 8020 + for (i = 0; i < config->rx_ring_num ; i++) 8021 + netif_napi_add(dev, &mac_control->rings[i].napi, 8022 + s2io_poll_msix, 64); 8023 + } else { 8024 + netif_napi_add(dev, &sp->napi, s2io_poll_inta, 64); 8019 8025 } 8020 8026 8021 8027 /* Not needed for Herc */ ··· 8093 8047 8094 8048 /* store mac addresses from CAM to s2io_nic structure */ 8095 8049 do_s2io_store_unicast_mc(sp); 8050 + 8051 + /* Configure MSIX vector for number of rings configured plus one */ 8052 + if ((sp->device_type == XFRAME_II_DEVICE) && 8053 + (config->intr_type == MSI_X)) 8054 + sp->num_entries = config->rx_ring_num + 1; 8096 8055 8097 8056 /* Store the values of the MSIX table in the s2io_nic structure */ 8098 8057 store_xmsi_data(sp); ··· 8164 8113 break; 8165 8114 } 8166 8115 8167 - if (napi) 8116 + switch (sp->config.napi) { 8117 + case 0: 8118 + DBG_PRINT(ERR_DBG, "%s: NAPI disabled\n", dev->name); 8119 + break; 8120 + case 1: 8168 8121 DBG_PRINT(ERR_DBG, "%s: NAPI enabled\n", dev->name); 8122 + break; 8123 + } 8169 8124 8170 8125 DBG_PRINT(ERR_DBG, "%s: Using %d Tx fifo(s)\n", dev->name, 8171 8126 sp->config.tx_fifo_num);
+12 -5
drivers/net/s2io.h
··· 706 706 /* per-ring buffer counter */ 707 707 u32 rx_bufs_left; 708 708 709 - #define MAX_LRO_SESSIONS 32 709 + #define MAX_LRO_SESSIONS 32 710 710 struct lro lro0_n[MAX_LRO_SESSIONS]; 711 711 u8 lro; 712 712 ··· 724 724 725 725 /* copy of sp->pdev pointer */ 726 726 struct pci_dev *pdev; 727 + 728 + /* Per ring napi struct */ 729 + struct napi_struct napi; 730 + 731 + unsigned long interrupt_count; 727 732 728 733 /* 729 734 * Place holders for the virtual and physical addresses of ··· 846 841 * Structure to keep track of the MSI-X vectors and the corresponding 847 842 * argument registered against each vector 848 843 */ 849 - #define MAX_REQUESTED_MSI_X 17 844 + #define MAX_REQUESTED_MSI_X 9 850 845 struct s2io_msix_entry 851 846 { 852 847 u16 vector; ··· 882 877 */ 883 878 int pkts_to_process; 884 879 struct net_device *dev; 885 - struct napi_struct napi; 886 880 struct mac_info mac_control; 887 881 struct config_param config; 888 882 struct pci_dev *pdev; ··· 952 948 */ 953 949 u8 other_fifo_idx; 954 950 951 + struct napi_struct napi; 955 952 /* after blink, the adapter must be restored with original 956 953 * values. 957 954 */ ··· 967 962 unsigned long long start_time; 968 963 struct vlan_group *vlgrp; 969 964 #define MSIX_FLG 0xA5 965 + int num_entries; 970 966 struct msix_entry *entries; 971 967 int msi_detected; 972 968 wait_queue_head_t msi_wait; ··· 1110 1104 static int init_shared_mem(struct s2io_nic *sp); 1111 1105 static void free_shared_mem(struct s2io_nic *sp); 1112 1106 static int init_nic(struct s2io_nic *nic); 1113 - static void rx_intr_handler(struct ring_info *ring_data); 1107 + static int rx_intr_handler(struct ring_info *ring_data, int budget); 1114 1108 static void tx_intr_handler(struct fifo_info *fifo_data); 1115 1109 static void s2io_handle_errors(void * dev_id); 1116 1110 ··· 1121 1115 static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp); 1122 1116 static void s2io_link(struct s2io_nic * sp, int link); 1123 1117 static void s2io_reset(struct s2io_nic * sp); 1124 - static int s2io_poll(struct napi_struct *napi, int budget); 1118 + static int s2io_poll_msix(struct napi_struct *napi, int budget); 1119 + static int s2io_poll_inta(struct napi_struct *napi, int budget); 1125 1120 static void s2io_init_pci(struct s2io_nic * sp); 1126 1121 static int do_s2io_prog_unicast(struct net_device *dev, u8 *addr); 1127 1122 static void s2io_alarm_handle(unsigned long data);