bnad.c (e0273728564a395a13cfed70e34da4f2613d2d44) | bnad.c (e1e0918fcaea7b8100ed9f96f3ecd9eb9b867102) |
---|---|
1/* 2 * Linux network driver for Brocade Converged Network Adapter. 3 * 4 * This program is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License (GPL) Version 2 as 6 * published by the Free Software Foundation 7 * 8 * This program is distributed in the hope that it will be useful, but --- 30 unchanged lines hidden (view full) --- 39static uint bnad_msix_disable; 40module_param(bnad_msix_disable, uint, 0444); 41MODULE_PARM_DESC(bnad_msix_disable, "Disable MSIX mode"); 42 43static uint bnad_ioc_auto_recover = 1; 44module_param(bnad_ioc_auto_recover, uint, 0444); 45MODULE_PARM_DESC(bnad_ioc_auto_recover, "Enable / Disable auto recovery"); 46 | 1/* 2 * Linux network driver for Brocade Converged Network Adapter. 3 * 4 * This program is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License (GPL) Version 2 as 6 * published by the Free Software Foundation 7 * 8 * This program is distributed in the hope that it will be useful, but --- 30 unchanged lines hidden (view full) --- 39static uint bnad_msix_disable; 40module_param(bnad_msix_disable, uint, 0444); 41MODULE_PARM_DESC(bnad_msix_disable, "Disable MSIX mode"); 42 43static uint bnad_ioc_auto_recover = 1; 44module_param(bnad_ioc_auto_recover, uint, 0444); 45MODULE_PARM_DESC(bnad_ioc_auto_recover, "Enable / Disable auto recovery"); 46 |
47static uint bna_debugfs_enable = 1; 48module_param(bna_debugfs_enable, uint, S_IRUGO | S_IWUSR); 49MODULE_PARM_DESC(bna_debugfs_enable, "Enables debugfs feature, default=1," 50 " Range[false:0|true:1]"); 51 |
|
47/* 48 * Global variables 49 */ 50u32 bnad_rxqs_per_cq = 2; | 52/* 53 * Global variables 54 */ 55u32 bnad_rxqs_per_cq = 2; |
51 | 56static u32 bna_id; 57static struct mutex bnad_list_mutex; 58static LIST_HEAD(bnad_list); |
52static const u8 bnad_bcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 53 54/* 55 * Local MACROS 56 */ 57#define BNAD_TX_UNMAPQ_DEPTH (bnad->txq_depth * 2) 58 59#define BNAD_RX_UNMAPQ_DEPTH (bnad->rxq_depth) --- 10 unchanged lines hidden (view full) --- 70 (_res_info)->res_u.mem_info.num = (_num); \ 71 (_res_info)->res_u.mem_info.len = \ 72 sizeof(struct bnad_unmap_q) + \ 73 (sizeof(struct bnad_skb_unmap) * ((_depth) - 1)); \ 74} while (0) 75 76#define BNAD_TXRX_SYNC_MDELAY 250 /* 250 msecs */ 77 | 59static const u8 bnad_bcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 60 61/* 62 * Local MACROS 63 */ 64#define BNAD_TX_UNMAPQ_DEPTH (bnad->txq_depth * 2) 65 66#define BNAD_RX_UNMAPQ_DEPTH (bnad->rxq_depth) --- 10 unchanged lines hidden (view full) --- 77 (_res_info)->res_u.mem_info.num = (_num); \ 78 (_res_info)->res_u.mem_info.len = \ 79 sizeof(struct bnad_unmap_q) + \ 80 (sizeof(struct bnad_skb_unmap) * ((_depth) - 1)); \ 81} while (0) 82 83#define BNAD_TXRX_SYNC_MDELAY 250 /* 250 msecs */ 84 |
85static void 86bnad_add_to_list(struct bnad *bnad) 87{ 88 mutex_lock(&bnad_list_mutex); 89 list_add_tail(&bnad->list_entry, &bnad_list); 90 bnad->id = bna_id++; 91 mutex_unlock(&bnad_list_mutex); 92} 93 94static void 95bnad_remove_from_list(struct bnad *bnad) 96{ 97 mutex_lock(&bnad_list_mutex); 98 list_del(&bnad->list_entry); 99 mutex_unlock(&bnad_list_mutex); 100} 101 |
|
78/* 79 * Reinitialize completions in CQ, once Rx is taken down 80 */ 81static void 82bnad_cq_cmpl_init(struct bnad *bnad, struct bna_ccb *ccb) 83{ 84 struct bna_cq_entry *cmpl, *next_cmpl; 85 unsigned int wi_range, wis = 0, ccb_prod = 0; --- 632 unchanged lines hidden (view full) --- 718 netif_carrier_off(bnad->netdev); 719 complete(&bnad->bnad_completions.enet_comp); 720} 721 722void 723bnad_cb_ethport_link_status(struct bnad *bnad, 724 enum bna_link_status link_status) 725{ | 102/* 103 * Reinitialize completions in CQ, once Rx is taken down 104 */ 105static void 106bnad_cq_cmpl_init(struct bnad *bnad, struct bna_ccb *ccb) 107{ 108 struct bna_cq_entry *cmpl, *next_cmpl; 109 unsigned int wi_range, wis = 0, ccb_prod = 0; --- 632 unchanged lines hidden (view full) --- 742 netif_carrier_off(bnad->netdev); 743 complete(&bnad->bnad_completions.enet_comp); 744} 745 746void 747bnad_cb_ethport_link_status(struct bnad *bnad, 748 enum bna_link_status link_status) 749{ |
726 bool link_up = 0; | 750 bool link_up = false; |
727 728 link_up = (link_status == BNA_LINK_UP) || (link_status == BNA_CEE_UP); 729 730 if (link_status == BNA_CEE_UP) { 731 if (!test_bit(BNAD_RF_CEE_RUNNING, &bnad->run_flags)) 732 BNAD_UPDATE_CTR(bnad, cee_toggle); 733 set_bit(BNAD_RF_CEE_RUNNING, &bnad->run_flags); 734 } else { --- 344 unchanged lines hidden (view full) --- 1079 1080static void 1081bnad_cb_enet_mtu_set(struct bnad *bnad) 1082{ 1083 bnad->bnad_completions.mtu_comp_status = BNA_CB_SUCCESS; 1084 complete(&bnad->bnad_completions.mtu_comp); 1085} 1086 | 751 752 link_up = (link_status == BNA_LINK_UP) || (link_status == BNA_CEE_UP); 753 754 if (link_status == BNA_CEE_UP) { 755 if (!test_bit(BNAD_RF_CEE_RUNNING, &bnad->run_flags)) 756 BNAD_UPDATE_CTR(bnad, cee_toggle); 757 set_bit(BNAD_RF_CEE_RUNNING, &bnad->run_flags); 758 } else { --- 344 unchanged lines hidden (view full) --- 1103 1104static void 1105bnad_cb_enet_mtu_set(struct bnad *bnad) 1106{ 1107 bnad->bnad_completions.mtu_comp_status = BNA_CB_SUCCESS; 1108 complete(&bnad->bnad_completions.mtu_comp); 1109} 1110 |
1111void 1112bnad_cb_completion(void *arg, enum bfa_status status) 1113{ 1114 struct bnad_iocmd_comp *iocmd_comp = 1115 (struct bnad_iocmd_comp *)arg; 1116 1117 iocmd_comp->comp_status = (u32) status; 1118 complete(&iocmd_comp->comp); 1119} 1120 |
|
1087/* Resource allocation, free functions */ 1088 1089static void 1090bnad_mem_free(struct bnad *bnad, 1091 struct bna_mem_info *mem_info) 1092{ 1093 int i; 1094 dma_addr_t dma_pa; --- 1868 unchanged lines hidden (view full) --- 2963 err = bnad_mtu_set(bnad, mtu); 2964 if (err) 2965 err = -EBUSY; 2966 2967 mutex_unlock(&bnad->conf_mutex); 2968 return err; 2969} 2970 | 1121/* Resource allocation, free functions */ 1122 1123static void 1124bnad_mem_free(struct bnad *bnad, 1125 struct bna_mem_info *mem_info) 1126{ 1127 int i; 1128 dma_addr_t dma_pa; --- 1868 unchanged lines hidden (view full) --- 2997 err = bnad_mtu_set(bnad, mtu); 2998 if (err) 2999 err = -EBUSY; 3000 3001 mutex_unlock(&bnad->conf_mutex); 3002 return err; 3003} 3004 |
2971static void | 3005static int |
2972bnad_vlan_rx_add_vid(struct net_device *netdev, 2973 unsigned short vid) 2974{ 2975 struct bnad *bnad = netdev_priv(netdev); 2976 unsigned long flags; 2977 2978 if (!bnad->rx_info[0].rx) | 3006bnad_vlan_rx_add_vid(struct net_device *netdev, 3007 unsigned short vid) 3008{ 3009 struct bnad *bnad = netdev_priv(netdev); 3010 unsigned long flags; 3011 3012 if (!bnad->rx_info[0].rx) |
2979 return; | 3013 return 0; |
2980 2981 mutex_lock(&bnad->conf_mutex); 2982 2983 spin_lock_irqsave(&bnad->bna_lock, flags); 2984 bna_rx_vlan_add(bnad->rx_info[0].rx, vid); 2985 set_bit(vid, bnad->active_vlans); 2986 spin_unlock_irqrestore(&bnad->bna_lock, flags); 2987 2988 mutex_unlock(&bnad->conf_mutex); | 3014 3015 mutex_lock(&bnad->conf_mutex); 3016 3017 spin_lock_irqsave(&bnad->bna_lock, flags); 3018 bna_rx_vlan_add(bnad->rx_info[0].rx, vid); 3019 set_bit(vid, bnad->active_vlans); 3020 spin_unlock_irqrestore(&bnad->bna_lock, flags); 3021 3022 mutex_unlock(&bnad->conf_mutex); |
3023 3024 return 0; |
|
2989} 2990 | 3025} 3026 |
2991static void | 3027static int |
2992bnad_vlan_rx_kill_vid(struct net_device *netdev, 2993 unsigned short vid) 2994{ 2995 struct bnad *bnad = netdev_priv(netdev); 2996 unsigned long flags; 2997 2998 if (!bnad->rx_info[0].rx) | 3028bnad_vlan_rx_kill_vid(struct net_device *netdev, 3029 unsigned short vid) 3030{ 3031 struct bnad *bnad = netdev_priv(netdev); 3032 unsigned long flags; 3033 3034 if (!bnad->rx_info[0].rx) |
2999 return; | 3035 return 0; |
3000 3001 mutex_lock(&bnad->conf_mutex); 3002 3003 spin_lock_irqsave(&bnad->bna_lock, flags); 3004 clear_bit(vid, bnad->active_vlans); 3005 bna_rx_vlan_del(bnad->rx_info[0].rx, vid); 3006 spin_unlock_irqrestore(&bnad->bna_lock, flags); 3007 3008 mutex_unlock(&bnad->conf_mutex); | 3036 3037 mutex_lock(&bnad->conf_mutex); 3038 3039 spin_lock_irqsave(&bnad->bna_lock, flags); 3040 clear_bit(vid, bnad->active_vlans); 3041 bna_rx_vlan_del(bnad->rx_info[0].rx, vid); 3042 spin_unlock_irqrestore(&bnad->bna_lock, flags); 3043 3044 mutex_unlock(&bnad->conf_mutex); |
3045 3046 return 0; |
|
3009} 3010 3011#ifdef CONFIG_NET_POLL_CONTROLLER 3012static void 3013bnad_netpoll(struct net_device *netdev) 3014{ 3015 struct bnad *bnad = netdev_priv(netdev); 3016 struct bnad_rx_info *rx_info; --- 141 unchanged lines hidden (view full) --- 3158 changes from OS interface 3159 b) spin lock used to protect bna state machine 3160 */ 3161static void 3162bnad_lock_init(struct bnad *bnad) 3163{ 3164 spin_lock_init(&bnad->bna_lock); 3165 mutex_init(&bnad->conf_mutex); | 3047} 3048 3049#ifdef CONFIG_NET_POLL_CONTROLLER 3050static void 3051bnad_netpoll(struct net_device *netdev) 3052{ 3053 struct bnad *bnad = netdev_priv(netdev); 3054 struct bnad_rx_info *rx_info; --- 141 unchanged lines hidden (view full) --- 3196 changes from OS interface 3197 b) spin lock used to protect bna state machine 3198 */ 3199static void 3200bnad_lock_init(struct bnad *bnad) 3201{ 3202 spin_lock_init(&bnad->bna_lock); 3203 mutex_init(&bnad->conf_mutex); |
3204 mutex_init(&bnad_list_mutex); |
|
3166} 3167 3168static void 3169bnad_lock_uninit(struct bnad *bnad) 3170{ 3171 mutex_destroy(&bnad->conf_mutex); | 3205} 3206 3207static void 3208bnad_lock_uninit(struct bnad *bnad) 3209{ 3210 mutex_destroy(&bnad->conf_mutex); |
3211 mutex_destroy(&bnad_list_mutex); |
|
3172} 3173 3174/* PCI Initialization */ 3175static int 3176bnad_pci_init(struct bnad *bnad, 3177 struct pci_dev *pdev, bool *using_dac) 3178{ 3179 int err; 3180 3181 err = pci_enable_device(pdev); 3182 if (err) 3183 return err; 3184 err = pci_request_regions(pdev, BNAD_NAME); 3185 if (err) 3186 goto disable_device; 3187 if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) && 3188 !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) { | 3212} 3213 3214/* PCI Initialization */ 3215static int 3216bnad_pci_init(struct bnad *bnad, 3217 struct pci_dev *pdev, bool *using_dac) 3218{ 3219 int err; 3220 3221 err = pci_enable_device(pdev); 3222 if (err) 3223 return err; 3224 err = pci_request_regions(pdev, BNAD_NAME); 3225 if (err) 3226 goto disable_device; 3227 if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) && 3228 !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) { |
3189 *using_dac = 1; | 3229 *using_dac = true; |
3190 } else { 3191 err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); 3192 if (err) { 3193 err = dma_set_coherent_mask(&pdev->dev, 3194 DMA_BIT_MASK(32)); 3195 if (err) 3196 goto release_regions; 3197 } | 3230 } else { 3231 err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); 3232 if (err) { 3233 err = dma_set_coherent_mask(&pdev->dev, 3234 DMA_BIT_MASK(32)); 3235 if (err) 3236 goto release_regions; 3237 } |
3198 *using_dac = 0; | 3238 *using_dac = false; |
3199 } 3200 pci_set_master(pdev); 3201 return 0; 3202 3203release_regions: 3204 pci_release_regions(pdev); 3205disable_device: 3206 pci_disable_device(pdev); --- 37 unchanged lines hidden (view full) --- 3244 */ 3245 netdev = alloc_etherdev(sizeof(struct bnad)); 3246 if (!netdev) { 3247 dev_err(&pdev->dev, "netdev allocation failed\n"); 3248 err = -ENOMEM; 3249 return err; 3250 } 3251 bnad = netdev_priv(netdev); | 3239 } 3240 pci_set_master(pdev); 3241 return 0; 3242 3243release_regions: 3244 pci_release_regions(pdev); 3245disable_device: 3246 pci_disable_device(pdev); --- 37 unchanged lines hidden (view full) --- 3284 */ 3285 netdev = alloc_etherdev(sizeof(struct bnad)); 3286 if (!netdev) { 3287 dev_err(&pdev->dev, "netdev allocation failed\n"); 3288 err = -ENOMEM; 3289 return err; 3290 } 3291 bnad = netdev_priv(netdev); |
3252 | |
3253 bnad_lock_init(bnad); | 3292 bnad_lock_init(bnad); |
3293 bnad_add_to_list(bnad); |
|
3254 3255 mutex_lock(&bnad->conf_mutex); 3256 /* 3257 * PCI initialization 3258 * Output : using_dac = 1 for 64 bit DMA 3259 * = 0 for 32 bit DMA 3260 */ 3261 err = bnad_pci_init(bnad, pdev, &using_dac); --- 10 unchanged lines hidden (view full) --- 3272 goto pci_uninit; 3273 3274 /* Initialize netdev structure, set up ethtool ops */ 3275 bnad_netdev_init(bnad, using_dac); 3276 3277 /* Set link to down state */ 3278 netif_carrier_off(netdev); 3279 | 3294 3295 mutex_lock(&bnad->conf_mutex); 3296 /* 3297 * PCI initialization 3298 * Output : using_dac = 1 for 64 bit DMA 3299 * = 0 for 32 bit DMA 3300 */ 3301 err = bnad_pci_init(bnad, pdev, &using_dac); --- 10 unchanged lines hidden (view full) --- 3312 goto pci_uninit; 3313 3314 /* Initialize netdev structure, set up ethtool ops */ 3315 bnad_netdev_init(bnad, using_dac); 3316 3317 /* Set link to down state */ 3318 netif_carrier_off(netdev); 3319 |
3320 /* Setup the debugfs node for this bfad */ 3321 if (bna_debugfs_enable) 3322 bnad_debugfs_init(bnad); 3323 |
|
3280 /* Get resource requirement form bna */ 3281 spin_lock_irqsave(&bnad->bna_lock, flags); 3282 bna_res_req(&bnad->res_info[0]); 3283 spin_unlock_irqrestore(&bnad->bna_lock, flags); 3284 3285 /* Allocate resources from bna */ 3286 err = bnad_res_alloc(bnad, &bnad->res_info[0], BNA_RES_T_MAX); 3287 if (err) --- 105 unchanged lines hidden (view full) --- 3393 spin_lock_irqsave(&bnad->bna_lock, flags); 3394 bna_uninit(bna); 3395 spin_unlock_irqrestore(&bnad->bna_lock, flags); 3396 bnad_mbox_irq_free(bnad); 3397 bnad_disable_msix(bnad); 3398res_free: 3399 bnad_res_free(bnad, &bnad->res_info[0], BNA_RES_T_MAX); 3400drv_uninit: | 3324 /* Get resource requirement form bna */ 3325 spin_lock_irqsave(&bnad->bna_lock, flags); 3326 bna_res_req(&bnad->res_info[0]); 3327 spin_unlock_irqrestore(&bnad->bna_lock, flags); 3328 3329 /* Allocate resources from bna */ 3330 err = bnad_res_alloc(bnad, &bnad->res_info[0], BNA_RES_T_MAX); 3331 if (err) --- 105 unchanged lines hidden (view full) --- 3437 spin_lock_irqsave(&bnad->bna_lock, flags); 3438 bna_uninit(bna); 3439 spin_unlock_irqrestore(&bnad->bna_lock, flags); 3440 bnad_mbox_irq_free(bnad); 3441 bnad_disable_msix(bnad); 3442res_free: 3443 bnad_res_free(bnad, &bnad->res_info[0], BNA_RES_T_MAX); 3444drv_uninit: |
3445 /* Remove the debugfs node for this bnad */ 3446 kfree(bnad->regdata); 3447 bnad_debugfs_uninit(bnad); |
|
3401 bnad_uninit(bnad); 3402pci_uninit: 3403 bnad_pci_uninit(pdev); 3404unlock_mutex: 3405 mutex_unlock(&bnad->conf_mutex); | 3448 bnad_uninit(bnad); 3449pci_uninit: 3450 bnad_pci_uninit(pdev); 3451unlock_mutex: 3452 mutex_unlock(&bnad->conf_mutex); |
3453 bnad_remove_from_list(bnad); |
|
3406 bnad_lock_uninit(bnad); 3407 free_netdev(netdev); 3408 return err; 3409} 3410 3411static void __devexit 3412bnad_pci_remove(struct pci_dev *pdev) 3413{ --- 22 unchanged lines hidden (view full) --- 3436 spin_unlock_irqrestore(&bnad->bna_lock, flags); 3437 3438 bnad_res_free(bnad, &bnad->mod_res_info[0], BNA_MOD_RES_T_MAX); 3439 bnad_res_free(bnad, &bnad->res_info[0], BNA_RES_T_MAX); 3440 bnad_mbox_irq_free(bnad); 3441 bnad_disable_msix(bnad); 3442 bnad_pci_uninit(pdev); 3443 mutex_unlock(&bnad->conf_mutex); | 3454 bnad_lock_uninit(bnad); 3455 free_netdev(netdev); 3456 return err; 3457} 3458 3459static void __devexit 3460bnad_pci_remove(struct pci_dev *pdev) 3461{ --- 22 unchanged lines hidden (view full) --- 3484 spin_unlock_irqrestore(&bnad->bna_lock, flags); 3485 3486 bnad_res_free(bnad, &bnad->mod_res_info[0], BNA_MOD_RES_T_MAX); 3487 bnad_res_free(bnad, &bnad->res_info[0], BNA_RES_T_MAX); 3488 bnad_mbox_irq_free(bnad); 3489 bnad_disable_msix(bnad); 3490 bnad_pci_uninit(pdev); 3491 mutex_unlock(&bnad->conf_mutex); |
3492 bnad_remove_from_list(bnad); |
|
3444 bnad_lock_uninit(bnad); | 3493 bnad_lock_uninit(bnad); |
3494 /* Remove the debugfs node for this bnad */ 3495 kfree(bnad->regdata); 3496 bnad_debugfs_uninit(bnad); |
|
3445 bnad_uninit(bnad); 3446 free_netdev(netdev); 3447} 3448 3449static DEFINE_PCI_DEVICE_TABLE(bnad_pci_id_table) = { 3450 { 3451 PCI_DEVICE(PCI_VENDOR_ID_BROCADE, 3452 PCI_DEVICE_ID_BROCADE_CT), --- 59 unchanged lines hidden --- | 3497 bnad_uninit(bnad); 3498 free_netdev(netdev); 3499} 3500 3501static DEFINE_PCI_DEVICE_TABLE(bnad_pci_id_table) = { 3502 { 3503 PCI_DEVICE(PCI_VENDOR_ID_BROCADE, 3504 PCI_DEVICE_ID_BROCADE_CT), --- 59 unchanged lines hidden --- |