bnad.c (3db1cd5c05f35fb43eb134df6f321de4e63141f2) bnad.c (72a9730b3f556e18912f3e1b494a7aee7ae3dd91)
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

--- 34 unchanged lines hidden (view full) ---

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
47/*
48 * Global variables
49 */
50u32 bnad_rxqs_per_cq = 2;
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

--- 34 unchanged lines hidden (view full) ---

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
47/*
48 * Global variables
49 */
50u32 bnad_rxqs_per_cq = 2;
51
51u32 bna_id;
52struct mutex bnad_list_mutex;
53LIST_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
54static const u8 bnad_bcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
55
56/*
57 * Local MACROS
58 */
59#define BNAD_TX_UNMAPQ_DEPTH (bnad->txq_depth * 2)
60
61#define BNAD_RX_UNMAPQ_DEPTH (bnad->rxq_depth)

--- 10 unchanged lines hidden (view full) ---

72 (_res_info)->res_u.mem_info.num = (_num); \
73 (_res_info)->res_u.mem_info.len = \
74 sizeof(struct bnad_unmap_q) + \
75 (sizeof(struct bnad_skb_unmap) * ((_depth) - 1)); \
76} while (0)
77
78#define BNAD_TXRX_SYNC_MDELAY 250 /* 250 msecs */
79
80static void
81bnad_add_to_list(struct bnad *bnad)
82{
83 mutex_lock(&bnad_list_mutex);
84 list_add_tail(&bnad->list_entry, &bnad_list);
85 bnad->id = bna_id++;
86 mutex_unlock(&bnad_list_mutex);
87}
88
89static void
90bnad_remove_from_list(struct bnad *bnad)
91{
92 mutex_lock(&bnad_list_mutex);
93 list_del(&bnad->list_entry);
94 mutex_unlock(&bnad_list_mutex);
95}
96
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;

--- 993 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
97/*
98 * Reinitialize completions in CQ, once Rx is taken down
99 */
100static void
101bnad_cq_cmpl_init(struct bnad *bnad, struct bna_ccb *ccb)
102{
103 struct bna_cq_entry *cmpl, *next_cmpl;
104 unsigned int wi_range, wis = 0, ccb_prod = 0;

--- 993 unchanged lines hidden (view full) ---

1098
1099static void
1100bnad_cb_enet_mtu_set(struct bnad *bnad)
1101{
1102 bnad->bnad_completions.mtu_comp_status = BNA_CB_SUCCESS;
1103 complete(&bnad->bnad_completions.mtu_comp);
1104}
1105
1106void
1107bnad_cb_completion(void *arg, enum bfa_status status)
1108{
1109 struct bnad_iocmd_comp *iocmd_comp =
1110 (struct bnad_iocmd_comp *)arg;
1111
1112 iocmd_comp->comp_status = (u32) status;
1113 complete(&iocmd_comp->comp);
1114}
1115
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;

--- 2067 unchanged lines hidden (view full) ---

3162 changes from OS interface
3163 b) spin lock used to protect bna state machine
3164 */
3165static void
3166bnad_lock_init(struct bnad *bnad)
3167{
3168 spin_lock_init(&bnad->bna_lock);
3169 mutex_init(&bnad->conf_mutex);
1116/* Resource allocation, free functions */
1117
1118static void
1119bnad_mem_free(struct bnad *bnad,
1120 struct bna_mem_info *mem_info)
1121{
1122 int i;
1123 dma_addr_t dma_pa;

--- 2067 unchanged lines hidden (view full) ---

3191 changes from OS interface
3192 b) spin lock used to protect bna state machine
3193 */
3194static void
3195bnad_lock_init(struct bnad *bnad)
3196{
3197 spin_lock_init(&bnad->bna_lock);
3198 mutex_init(&bnad->conf_mutex);
3199 mutex_init(&bnad_list_mutex);
3170}
3171
3172static void
3173bnad_lock_uninit(struct bnad *bnad)
3174{
3175 mutex_destroy(&bnad->conf_mutex);
3200}
3201
3202static void
3203bnad_lock_uninit(struct bnad *bnad)
3204{
3205 mutex_destroy(&bnad->conf_mutex);
3206 mutex_destroy(&bnad_list_mutex);
3176}
3177
3178/* PCI Initialization */
3179static int
3180bnad_pci_init(struct bnad *bnad,
3181 struct pci_dev *pdev, bool *using_dac)
3182{
3183 int err;

--- 64 unchanged lines hidden (view full) ---

3248 */
3249 netdev = alloc_etherdev(sizeof(struct bnad));
3250 if (!netdev) {
3251 dev_err(&pdev->dev, "netdev allocation failed\n");
3252 err = -ENOMEM;
3253 return err;
3254 }
3255 bnad = netdev_priv(netdev);
3207}
3208
3209/* PCI Initialization */
3210static int
3211bnad_pci_init(struct bnad *bnad,
3212 struct pci_dev *pdev, bool *using_dac)
3213{
3214 int err;

--- 64 unchanged lines hidden (view full) ---

3279 */
3280 netdev = alloc_etherdev(sizeof(struct bnad));
3281 if (!netdev) {
3282 dev_err(&pdev->dev, "netdev allocation failed\n");
3283 err = -ENOMEM;
3284 return err;
3285 }
3286 bnad = netdev_priv(netdev);
3256
3257 bnad_lock_init(bnad);
3287 bnad_lock_init(bnad);
3288 bnad_add_to_list(bnad);
3258
3259 mutex_lock(&bnad->conf_mutex);
3260 /*
3261 * PCI initialization
3262 * Output : using_dac = 1 for 64 bit DMA
3263 * = 0 for 32 bit DMA
3264 */
3265 err = bnad_pci_init(bnad, pdev, &using_dac);

--- 136 unchanged lines hidden (view full) ---

3402res_free:
3403 bnad_res_free(bnad, &bnad->res_info[0], BNA_RES_T_MAX);
3404drv_uninit:
3405 bnad_uninit(bnad);
3406pci_uninit:
3407 bnad_pci_uninit(pdev);
3408unlock_mutex:
3409 mutex_unlock(&bnad->conf_mutex);
3289
3290 mutex_lock(&bnad->conf_mutex);
3291 /*
3292 * PCI initialization
3293 * Output : using_dac = 1 for 64 bit DMA
3294 * = 0 for 32 bit DMA
3295 */
3296 err = bnad_pci_init(bnad, pdev, &using_dac);

--- 136 unchanged lines hidden (view full) ---

3433res_free:
3434 bnad_res_free(bnad, &bnad->res_info[0], BNA_RES_T_MAX);
3435drv_uninit:
3436 bnad_uninit(bnad);
3437pci_uninit:
3438 bnad_pci_uninit(pdev);
3439unlock_mutex:
3440 mutex_unlock(&bnad->conf_mutex);
3441 bnad_remove_from_list(bnad);
3410 bnad_lock_uninit(bnad);
3411 free_netdev(netdev);
3412 return err;
3413}
3414
3415static void __devexit
3416bnad_pci_remove(struct pci_dev *pdev)
3417{

--- 22 unchanged lines hidden (view full) ---

3440 spin_unlock_irqrestore(&bnad->bna_lock, flags);
3441
3442 bnad_res_free(bnad, &bnad->mod_res_info[0], BNA_MOD_RES_T_MAX);
3443 bnad_res_free(bnad, &bnad->res_info[0], BNA_RES_T_MAX);
3444 bnad_mbox_irq_free(bnad);
3445 bnad_disable_msix(bnad);
3446 bnad_pci_uninit(pdev);
3447 mutex_unlock(&bnad->conf_mutex);
3442 bnad_lock_uninit(bnad);
3443 free_netdev(netdev);
3444 return err;
3445}
3446
3447static void __devexit
3448bnad_pci_remove(struct pci_dev *pdev)
3449{

--- 22 unchanged lines hidden (view full) ---

3472 spin_unlock_irqrestore(&bnad->bna_lock, flags);
3473
3474 bnad_res_free(bnad, &bnad->mod_res_info[0], BNA_MOD_RES_T_MAX);
3475 bnad_res_free(bnad, &bnad->res_info[0], BNA_RES_T_MAX);
3476 bnad_mbox_irq_free(bnad);
3477 bnad_disable_msix(bnad);
3478 bnad_pci_uninit(pdev);
3479 mutex_unlock(&bnad->conf_mutex);
3480 bnad_remove_from_list(bnad);
3448 bnad_lock_uninit(bnad);
3449 bnad_uninit(bnad);
3450 free_netdev(netdev);
3451}
3452
3453static DEFINE_PCI_DEVICE_TABLE(bnad_pci_id_table) = {
3454 {
3455 PCI_DEVICE(PCI_VENDOR_ID_BROCADE,

--- 60 unchanged lines hidden ---
3481 bnad_lock_uninit(bnad);
3482 bnad_uninit(bnad);
3483 free_netdev(netdev);
3484}
3485
3486static DEFINE_PCI_DEVICE_TABLE(bnad_pci_id_table) = {
3487 {
3488 PCI_DEVICE(PCI_VENDOR_ID_BROCADE,

--- 60 unchanged lines hidden ---