Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1 | #include "headers.h" |
| 2 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 3 | static int BcmFileDownload(struct bcm_mini_adapter *Adapter, const char *path, unsigned int loc); |
Kevin McKinney | 7a15b79 | 2012-10-18 22:40:08 -0400 | [diff] [blame] | 4 | static void doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter); |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 5 | static void HandleShutDownModeRequest(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer); |
| 6 | static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter); |
| 7 | static void beceem_protocol_reset(struct bcm_mini_adapter *Adapter); |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 8 | |
Kevin McKinney | 7a15b79 | 2012-10-18 22:40:08 -0400 | [diff] [blame] | 9 | static void default_wimax_protocol_initialize(struct bcm_mini_adapter *Adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 10 | { |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 11 | unsigned int uiLoopIndex; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 12 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 13 | for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES-1; uiLoopIndex++) { |
| 14 | Adapter->PackInfo[uiLoopIndex].uiThreshold = TX_PACKET_THRESHOLD; |
| 15 | Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate = MAX_ALLOWED_RATE; |
| 16 | Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize = 20*1024*1024; |
| 17 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 18 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 19 | Adapter->BEBucketSize = BE_BUCKET_SIZE; |
| 20 | Adapter->rtPSBucketSize = rtPS_BUCKET_SIZE; |
| 21 | Adapter->LinkStatus = SYNC_UP_REQUEST; |
| 22 | Adapter->TransferMode = IP_PACKET_ONLY_MODE; |
| 23 | Adapter->usBestEffortQueueIndex = -1; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 24 | } |
| 25 | |
Kevin McKinney | 7af14134 | 2012-10-18 22:40:13 -0400 | [diff] [blame] | 26 | int InitAdapter(struct bcm_mini_adapter *psAdapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 27 | { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 28 | int i = 0; |
Kevin McKinney | 7af14134 | 2012-10-18 22:40:13 -0400 | [diff] [blame] | 29 | int Status = STATUS_SUCCESS; |
Robin Schroer | fe83073 | 2014-06-16 13:01:46 +0200 | [diff] [blame] | 30 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 31 | BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Initialising Adapter = %p", psAdapter); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 32 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 33 | if (psAdapter == NULL) { |
| 34 | BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter is NULL"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 35 | return -EINVAL; |
| 36 | } |
| 37 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 38 | sema_init(&psAdapter->NVMRdmWrmLock, 1); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 39 | sema_init(&psAdapter->rdmwrmsync, 1); |
| 40 | spin_lock_init(&psAdapter->control_queue_lock); |
| 41 | spin_lock_init(&psAdapter->txtransmitlock); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 42 | sema_init(&psAdapter->RxAppControlQueuelock, 1); |
| 43 | sema_init(&psAdapter->fw_download_sema, 1); |
| 44 | sema_init(&psAdapter->LowPowerModeSync, 1); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 45 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 46 | for (i = 0; i < NO_OF_QUEUES; i++) |
| 47 | spin_lock_init(&psAdapter->PackInfo[i].SFQueueLock); |
| 48 | i = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 49 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 50 | init_waitqueue_head(&psAdapter->process_rx_cntrlpkt); |
| 51 | init_waitqueue_head(&psAdapter->tx_packet_wait_queue); |
| 52 | init_waitqueue_head(&psAdapter->process_read_wait_queue); |
| 53 | init_waitqueue_head(&psAdapter->ioctl_fw_dnld_wait_queue); |
| 54 | init_waitqueue_head(&psAdapter->lowpower_mode_wait_queue); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 55 | psAdapter->waiting_to_fw_download_done = TRUE; |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 56 | psAdapter->fw_download_done = false; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 57 | |
| 58 | default_wimax_protocol_initialize(psAdapter); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 59 | for (i = 0; i < MAX_CNTRL_PKTS; i++) { |
Jesper Juhl | 3701bef | 2010-11-10 21:31:38 +0100 | [diff] [blame] | 60 | psAdapter->txctlpacket[i] = kmalloc(MAX_CNTL_PKT_SIZE, GFP_KERNEL); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 61 | if (!psAdapter->txctlpacket[i]) { |
| 62 | BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No More Cntl pkts got, max got is %d", i); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 63 | return -ENOMEM; |
| 64 | } |
| 65 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 66 | |
| 67 | if (AllocAdapterDsxBuffer(psAdapter)) { |
| 68 | BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to allocate DSX buffers"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 69 | return -EINVAL; |
| 70 | } |
| 71 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 72 | /* Initialize PHS interface */ |
| 73 | if (phs_init(&psAdapter->stBCMPhsContext, psAdapter) != 0) { |
Kevin McKinney | a8a1cdd | 2011-10-07 18:50:10 -0400 | [diff] [blame] | 74 | BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%s:%d:Error PHS Init Failed=====>\n", __FILE__, __func__, __LINE__); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 75 | return -ENOMEM; |
| 76 | } |
| 77 | |
| 78 | Status = BcmAllocFlashCSStructure(psAdapter); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 79 | if (Status) { |
| 80 | BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Memory Allocation for Flash structure failed"); |
| 81 | return Status; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | Status = vendorextnInit(psAdapter); |
| 85 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 86 | if (STATUS_SUCCESS != Status) { |
| 87 | BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Vendor Init Failed"); |
| 88 | return Status; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 91 | BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter initialised"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 92 | |
| 93 | return STATUS_SUCCESS; |
| 94 | } |
| 95 | |
Kevin McKinney | 7a15b79 | 2012-10-18 22:40:08 -0400 | [diff] [blame] | 96 | void AdapterFree(struct bcm_mini_adapter *Adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 97 | { |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 98 | int count; |
Robin Schroer | fe83073 | 2014-06-16 13:01:46 +0200 | [diff] [blame] | 99 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 100 | beceem_protocol_reset(Adapter); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 101 | vendorextnExit(Adapter); |
| 102 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 103 | if (Adapter->control_packet_handler && !IS_ERR(Adapter->control_packet_handler)) |
| 104 | kthread_stop(Adapter->control_packet_handler); |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 105 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 106 | if (Adapter->transmit_packet_thread && !IS_ERR(Adapter->transmit_packet_thread)) |
| 107 | kthread_stop(Adapter->transmit_packet_thread); |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 108 | |
| 109 | wake_up(&Adapter->process_read_wait_queue); |
| 110 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 111 | if (Adapter->LEDInfo.led_thread_running & (BCM_LED_THREAD_RUNNING_ACTIVELY | BCM_LED_THREAD_RUNNING_INACTIVELY)) |
| 112 | kthread_stop(Adapter->LEDInfo.led_cntrl_threadid); |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 113 | |
Stephen Hemminger | 4ea4f7a | 2010-11-01 14:06:24 -0400 | [diff] [blame] | 114 | unregister_networkdev(Adapter); |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 115 | |
| 116 | /* FIXME: use proper wait_event and refcounting */ |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 117 | while (atomic_read(&Adapter->ApplicationRunning)) { |
| 118 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Waiting for Application to close.. %d\n", atomic_read(&Adapter->ApplicationRunning)); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 119 | msleep(100); |
| 120 | } |
| 121 | unregister_control_device_interface(Adapter); |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 122 | kfree(Adapter->pstargetparams); |
| 123 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 124 | for (count = 0; count < MAX_CNTRL_PKTS; count++) |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 125 | kfree(Adapter->txctlpacket[count]); |
| 126 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 127 | FreeAdapterDsxBuffer(Adapter); |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 128 | kfree(Adapter->pvInterfaceAdapter); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 129 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 130 | /* Free the PHS Interface */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 131 | PhsCleanup(&Adapter->stBCMPhsContext); |
| 132 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 133 | BcmDeAllocFlashCSStructure(Adapter); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 134 | |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 135 | free_netdev(Adapter->dev); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 138 | static int create_worker_threads(struct bcm_mini_adapter *psAdapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 139 | { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 140 | /* Rx Control Packets Processing */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 141 | psAdapter->control_packet_handler = kthread_run((int (*)(void *)) |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 142 | control_packet_handler, psAdapter, "%s-rx", DRV_NAME); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 143 | if (IS_ERR(psAdapter->control_packet_handler)) { |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 144 | pr_notice(DRV_NAME ": could not create control thread\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 145 | return PTR_ERR(psAdapter->control_packet_handler); |
| 146 | } |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 147 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 148 | /* Tx Thread */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 149 | psAdapter->transmit_packet_thread = kthread_run((int (*)(void *)) |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 150 | tx_pkt_handler, psAdapter, "%s-tx", DRV_NAME); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 151 | if (IS_ERR(psAdapter->transmit_packet_thread)) { |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 152 | pr_notice(DRV_NAME ": could not creat transmit thread\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 153 | kthread_stop(psAdapter->control_packet_handler); |
| 154 | return PTR_ERR(psAdapter->transmit_packet_thread); |
| 155 | } |
| 156 | return 0; |
| 157 | } |
| 158 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 159 | static struct file *open_firmware_file(struct bcm_mini_adapter *Adapter, const char *path) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 160 | { |
Al Viro | 32aecdd | 2012-07-22 21:02:01 +0400 | [diff] [blame] | 161 | struct file *flp = filp_open(path, O_RDONLY, S_IRWXU); |
Robin Schroer | fe83073 | 2014-06-16 13:01:46 +0200 | [diff] [blame] | 162 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 163 | if (IS_ERR(flp)) { |
| 164 | pr_err(DRV_NAME "Unable To Open File %s, err %ld", path, PTR_ERR(flp)); |
| 165 | flp = NULL; |
| 166 | } |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 167 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 168 | if (Adapter->device_removed) |
| 169 | flp = NULL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 170 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 171 | return flp; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 172 | } |
| 173 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 174 | /* Arguments: |
| 175 | * Logical Adapter |
| 176 | * Path to image file |
| 177 | * Download Address on the chip |
| 178 | */ |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 179 | static int BcmFileDownload(struct bcm_mini_adapter *Adapter, const char *path, unsigned int loc) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 180 | { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 181 | int errorno = 0; |
| 182 | struct file *flp = NULL; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 183 | struct timeval tv = {0}; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 184 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 185 | flp = open_firmware_file(Adapter, path); |
| 186 | if (!flp) { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 187 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable to Open %s\n", path); |
Al Viro | 32aecdd | 2012-07-22 21:02:01 +0400 | [diff] [blame] | 188 | return -ENOENT; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 189 | } |
Al Viro | 496ad9a | 2013-01-23 17:07:38 -0500 | [diff] [blame] | 190 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Opened file is = %s and length =0x%lx to be downloaded at =0x%x", path, (unsigned long)file_inode(flp)->i_size, loc); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 191 | do_gettimeofday(&tv); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 192 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 193 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "download start %lx", ((tv.tv_sec * 1000) + (tv.tv_usec / 1000))); |
| 194 | if (Adapter->bcm_file_download(Adapter->pvInterfaceAdapter, flp, loc)) { |
| 195 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to download the firmware with error %x!!!", -EIO); |
| 196 | errorno = -EIO; |
| 197 | goto exit_download; |
| 198 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 199 | vfs_llseek(flp, 0, 0); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 200 | if (Adapter->bcm_file_readback_from_chip(Adapter->pvInterfaceAdapter, flp, loc)) { |
| 201 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to read back firmware!"); |
| 202 | errorno = -EIO; |
| 203 | goto exit_download; |
| 204 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 205 | |
| 206 | exit_download: |
Al Viro | 32aecdd | 2012-07-22 21:02:01 +0400 | [diff] [blame] | 207 | filp_close(flp, NULL); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 208 | return errorno; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 209 | } |
| 210 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 211 | /** |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 212 | * @ingroup ctrl_pkt_functions |
| 213 | * This function copies the contents of given buffer |
| 214 | * to the control packet and queues it for transmission. |
Masanari Iida | 6abaf58 | 2013-08-23 22:55:31 +0900 | [diff] [blame] | 215 | * @note Do not acquire the spinlock, as it it already acquired. |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 216 | * @return SUCCESS/FAILURE. |
| 217 | * Arguments: |
| 218 | * Logical Adapter |
| 219 | * Control Packet Buffer |
| 220 | */ |
Kevin McKinney | 7af14134 | 2012-10-18 22:40:13 -0400 | [diff] [blame] | 221 | int CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter, void *ioBuffer) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 222 | { |
Kevin McKinney | ff35204 | 2012-05-26 12:05:11 -0400 | [diff] [blame] | 223 | struct bcm_leader *pLeader = NULL; |
Kevin McKinney | 7af14134 | 2012-10-18 22:40:13 -0400 | [diff] [blame] | 224 | int Status = 0; |
Kevin McKinney | 895b1fb | 2012-10-18 22:40:14 -0400 | [diff] [blame] | 225 | unsigned char *ctrl_buff; |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 226 | unsigned int pktlen = 0; |
Kevin McKinney | 2610c7a | 2012-05-26 12:05:08 -0400 | [diff] [blame] | 227 | struct bcm_link_request *pLinkReq = NULL; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 228 | PUCHAR pucAddIndication = NULL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 229 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 230 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "======>"); |
| 231 | if (!ioBuffer) { |
| 232 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Got Null Buffer\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 233 | return -EINVAL; |
| 234 | } |
| 235 | |
Kevin McKinney | 2610c7a | 2012-05-26 12:05:08 -0400 | [diff] [blame] | 236 | pLinkReq = (struct bcm_link_request *)ioBuffer; |
Kevin McKinney | ff35204 | 2012-05-26 12:05:11 -0400 | [diff] [blame] | 237 | pLeader = (struct bcm_leader *)ioBuffer; /* ioBuffer Contains sw_Status and Payload */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 238 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 239 | if (Adapter->bShutStatus == TRUE && |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 240 | pLinkReq->szData[0] == LINK_DOWN_REQ_PAYLOAD && |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 241 | pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE) { |
| 242 | |
| 243 | /* Got sync down in SHUTDOWN..we could not process this. */ |
| 244 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "SYNC DOWN Request in Shut Down Mode..\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 245 | return STATUS_FAILURE; |
| 246 | } |
| 247 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 248 | if ((pLeader->Status == LINK_UP_CONTROL_REQ) && |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 249 | ((pLinkReq->szData[0] == LINK_UP_REQ_PAYLOAD && |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 250 | (pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE)) || /* Sync Up Command */ |
| 251 | pLinkReq->szData[0] == NETWORK_ENTRY_REQ_PAYLOAD)) /* Net Entry Command */ { |
| 252 | |
| 253 | if (Adapter->LinkStatus > PHY_SYNC_ACHIVED) { |
| 254 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "LinkStatus is Greater than PHY_SYN_ACHIEVED"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 255 | return STATUS_FAILURE; |
| 256 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 257 | |
Kevin McKinney | b64c846 | 2012-10-18 22:40:15 -0400 | [diff] [blame] | 258 | if (Adapter->bShutStatus == TRUE) { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 259 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "SYNC UP IN SHUTDOWN..Device WakeUp\n"); |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 260 | if (Adapter->bTriedToWakeUpFromlowPowerMode == false) { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 261 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Waking up for the First Time..\n"); |
| 262 | Adapter->usIdleModePattern = ABORT_SHUTDOWN_MODE; /* change it to 1 for current support. */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 263 | Adapter->bWakeUpDevice = TRUE; |
| 264 | wake_up(&Adapter->process_rx_cntrlpkt); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 265 | Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, !Adapter->bShutStatus, (5 * HZ)); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 266 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 267 | if (Status == -ERESTARTSYS) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 268 | return Status; |
| 269 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 270 | if (Adapter->bShutStatus) { |
| 271 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Shutdown Mode Wake up Failed - No Wake Up Received\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 272 | return STATUS_FAILURE; |
| 273 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 274 | } else { |
| 275 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Wakeup has been tried already...\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 276 | } |
| 277 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 278 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 279 | |
Kevin McKinney | b64c846 | 2012-10-18 22:40:15 -0400 | [diff] [blame] | 280 | if (Adapter->IdleMode == TRUE) { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 281 | /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle mode ... hence\n"); */ |
| 282 | if (pLeader->Status == LINK_UP_CONTROL_REQ || pLeader->Status == 0x80 || |
| 283 | pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ) { |
| 284 | |
| 285 | if ((pLeader->Status == LINK_UP_CONTROL_REQ) && (pLinkReq->szData[0] == LINK_DOWN_REQ_PAYLOAD)) { |
Robin Schroer | 28c520a | 2014-06-16 13:01:47 +0200 | [diff] [blame] | 286 | if (pLinkReq->szData[1] == LINK_SYNC_DOWN_SUBTYPE) { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 287 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Link Down Sent in Idle Mode\n"); |
| 288 | Adapter->usIdleModePattern = ABORT_IDLE_SYNCDOWN; /* LINK DOWN sent in Idle Mode */ |
| 289 | } else { |
| 290 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "ABORT_IDLE_MODE pattern is being written\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 291 | Adapter->usIdleModePattern = ABORT_IDLE_REG; |
| 292 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 293 | } else { |
| 294 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "ABORT_IDLE_MODE pattern is being written\n"); |
| 295 | Adapter->usIdleModePattern = ABORT_IDLE_MODE; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | /*Setting bIdleMode_tx_from_host to TRUE to indicate LED control thread to represent |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 299 | * the wake up from idlemode is from host |
| 300 | */ |
| 301 | /* Adapter->LEDInfo.bIdleMode_tx_from_host = TRUE; */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 302 | Adapter->bWakeUpDevice = TRUE; |
| 303 | wake_up(&Adapter->process_rx_cntrlpkt); |
| 304 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 305 | /* We should not send DREG message down while in idlemode. */ |
| 306 | if (LINK_DOWN_REQ_PAYLOAD == pLinkReq->szData[0]) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 307 | return STATUS_SUCCESS; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 308 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 309 | Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, !Adapter->IdleMode, (5 * HZ)); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 310 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 311 | if (Status == -ERESTARTSYS) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 312 | return Status; |
| 313 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 314 | if (Adapter->IdleMode) { |
| 315 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Idle Mode Wake up Failed - No Wake Up Received\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 316 | return STATUS_FAILURE; |
| 317 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 318 | } else { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 319 | return STATUS_SUCCESS; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 320 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 321 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 322 | |
| 323 | /* The Driver has to send control messages with a particular VCID */ |
| 324 | pLeader->Vcid = VCID_CONTROL_PACKET; /* VCID for control packet. */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 325 | |
| 326 | /* Allocate skb for Control Packet */ |
| 327 | pktlen = pLeader->PLength; |
| 328 | ctrl_buff = (char *)Adapter->txctlpacket[atomic_read(&Adapter->index_wr_txcntrlpkt)%MAX_CNTRL_PKTS]; |
| 329 | |
Kevin McKinney | 895b1fb | 2012-10-18 22:40:14 -0400 | [diff] [blame] | 330 | if (!ctrl_buff) { |
| 331 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "mem allocation Failed"); |
| 332 | return -ENOMEM; |
| 333 | } |
| 334 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 335 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Control packet to be taken =%d and address is =%pincoming address is =%p and packet len=%x", |
| 336 | atomic_read(&Adapter->index_wr_txcntrlpkt), ctrl_buff, ioBuffer, pktlen); |
Kevin McKinney | 895b1fb | 2012-10-18 22:40:14 -0400 | [diff] [blame] | 337 | |
| 338 | if (pLeader) { |
| 339 | if ((pLeader->Status == 0x80) || |
| 340 | (pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ)) { |
| 341 | /* |
| 342 | * Restructure the DSX message to handle Multiple classifier Support |
| 343 | * Write the Service Flow param Structures directly to the target |
| 344 | * and embed the pointers in the DSX messages sent to target. |
| 345 | */ |
| 346 | /* Lets store the current length of the control packet we are transmitting */ |
| 347 | pucAddIndication = (PUCHAR)ioBuffer + LEADER_SIZE; |
| 348 | pktlen = pLeader->PLength; |
| 349 | Status = StoreCmControlResponseMessage(Adapter, pucAddIndication, &pktlen); |
| 350 | if (Status != 1) { |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 351 | ClearTargetDSXBuffer(Adapter, ((struct bcm_add_indication_alt *)pucAddIndication)->u16TID, false); |
Kevin McKinney | 895b1fb | 2012-10-18 22:40:14 -0400 | [diff] [blame] | 352 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, " Error Restoring The DSX Control Packet. Dsx Buffers on Target may not be Setup Properly "); |
| 353 | return STATUS_FAILURE; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 354 | } |
Kevin McKinney | 895b1fb | 2012-10-18 22:40:14 -0400 | [diff] [blame] | 355 | /* |
| 356 | * update the leader to use the new length |
| 357 | * The length of the control packet is length of message being sent + Leader length |
| 358 | */ |
| 359 | pLeader->PLength = pktlen; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 360 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 361 | } |
Kevin McKinney | 895b1fb | 2012-10-18 22:40:14 -0400 | [diff] [blame] | 362 | |
| 363 | if (pktlen + LEADER_SIZE > MAX_CNTL_PKT_SIZE) |
| 364 | return -EINVAL; |
| 365 | |
| 366 | memset(ctrl_buff, 0, pktlen+LEADER_SIZE); |
| 367 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Copying the Control Packet Buffer with length=%d\n", pLeader->PLength); |
| 368 | *(struct bcm_leader *)ctrl_buff = *pLeader; |
| 369 | memcpy(ctrl_buff + LEADER_SIZE, ((PUCHAR)ioBuffer + LEADER_SIZE), pLeader->PLength); |
| 370 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Enqueuing the Control Packet"); |
| 371 | |
| 372 | /* Update the statistics counters */ |
| 373 | spin_lock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock); |
| 374 | Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost += pLeader->PLength; |
| 375 | Adapter->PackInfo[HiPriority].uiCurrentPacketsOnHost++; |
| 376 | atomic_inc(&Adapter->TotalPacketCount); |
| 377 | spin_unlock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock); |
| 378 | Adapter->PackInfo[HiPriority].bValid = TRUE; |
| 379 | |
| 380 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "CurrBytesOnHost: %x bValid: %x", |
| 381 | Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost, |
| 382 | Adapter->PackInfo[HiPriority].bValid); |
| 383 | Status = STATUS_SUCCESS; |
| 384 | /*Queue the packet for transmission */ |
| 385 | atomic_inc(&Adapter->index_wr_txcntrlpkt); |
| 386 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Calling transmit_packets"); |
| 387 | atomic_set(&Adapter->TxPktAvail, 1); |
| 388 | wake_up(&Adapter->tx_packet_wait_queue); |
| 389 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 390 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "<===="); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 391 | return Status; |
| 392 | } |
| 393 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 394 | /****************************************************************** |
| 395 | * Function - LinkMessage() |
| 396 | * |
| 397 | * Description - This function builds the Sync-up and Link-up request |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 398 | * packet messages depending on the device Link status. |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 399 | * |
| 400 | * Parameters - Adapter: Pointer to the Adapter structure. |
| 401 | * |
| 402 | * Returns - None. |
| 403 | *******************************************************************/ |
Kevin McKinney | 7a15b79 | 2012-10-18 22:40:08 -0400 | [diff] [blame] | 404 | void LinkMessage(struct bcm_mini_adapter *Adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 405 | { |
Kevin McKinney | 2610c7a | 2012-05-26 12:05:08 -0400 | [diff] [blame] | 406 | struct bcm_link_request *pstLinkRequest = NULL; |
Robin Schroer | fe83073 | 2014-06-16 13:01:46 +0200 | [diff] [blame] | 407 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 408 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "=====>"); |
| 409 | if (Adapter->LinkStatus == SYNC_UP_REQUEST && Adapter->AutoSyncup) { |
Kevin McKinney | 2610c7a | 2012-05-26 12:05:08 -0400 | [diff] [blame] | 410 | pstLinkRequest = kzalloc(sizeof(struct bcm_link_request), GFP_ATOMIC); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 411 | if (!pstLinkRequest) { |
| 412 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 413 | return; |
| 414 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 415 | /* sync up request... */ |
| 416 | Adapter->LinkStatus = WAIT_FOR_SYNC; /* current link status */ |
| 417 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For SyncUp..."); |
| 418 | pstLinkRequest->szData[0] = LINK_UP_REQ_PAYLOAD; |
| 419 | pstLinkRequest->szData[1] = LINK_SYNC_UP_SUBTYPE; |
| 420 | pstLinkRequest->Leader.Status = LINK_UP_CONTROL_REQ; |
| 421 | pstLinkRequest->Leader.PLength = sizeof(ULONG); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 422 | Adapter->bSyncUpRequestSent = TRUE; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 423 | |
| 424 | } else if (Adapter->LinkStatus == PHY_SYNC_ACHIVED && Adapter->AutoLinkUp) { |
Kevin McKinney | 2610c7a | 2012-05-26 12:05:08 -0400 | [diff] [blame] | 425 | pstLinkRequest = kzalloc(sizeof(struct bcm_link_request), GFP_ATOMIC); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 426 | if (!pstLinkRequest) { |
| 427 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 428 | return; |
| 429 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 430 | /* LINK_UP_REQUEST */ |
| 431 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For LinkUp..."); |
| 432 | pstLinkRequest->szData[0] = LINK_UP_REQ_PAYLOAD; |
| 433 | pstLinkRequest->szData[1] = LINK_NET_ENTRY; |
| 434 | pstLinkRequest->Leader.Status = LINK_UP_CONTROL_REQ; |
| 435 | pstLinkRequest->Leader.PLength = sizeof(ULONG); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 436 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 437 | if (pstLinkRequest) { |
| 438 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Calling CopyBufferToControlPacket"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 439 | CopyBufferToControlPacket(Adapter, pstLinkRequest); |
Stephen Hemminger | 082e889 | 2010-11-01 09:35:21 -0400 | [diff] [blame] | 440 | kfree(pstLinkRequest); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 441 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 442 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "LinkMessage <====="); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 443 | return; |
| 444 | } |
| 445 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 446 | /********************************************************************** |
| 447 | * Function - StatisticsResponse() |
| 448 | * |
| 449 | * Description - This function handles the Statistics response packet. |
| 450 | * |
| 451 | * Parameters - Adapter : Pointer to the Adapter structure. |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 452 | * - pvBuffer: Starting address of Statistic response data. |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 453 | * |
| 454 | * Returns - None. |
| 455 | ************************************************************************/ |
Kevin McKinney | 7a15b79 | 2012-10-18 22:40:08 -0400 | [diff] [blame] | 456 | void StatisticsResponse(struct bcm_mini_adapter *Adapter, void *pvBuffer) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 457 | { |
Kevin McKinney | a8a1cdd | 2011-10-07 18:50:10 -0400 | [diff] [blame] | 458 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>", __func__); |
Stephen Hemminger | e39e3be | 2010-11-01 11:14:29 -0400 | [diff] [blame] | 459 | Adapter->StatisticsPointer = ntohl(*(__be32 *)pvBuffer); |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 460 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Stats at %x", (unsigned int)Adapter->StatisticsPointer); |
Kevin McKinney | a8a1cdd | 2011-10-07 18:50:10 -0400 | [diff] [blame] | 461 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s <====", __func__); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 462 | } |
| 463 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 464 | /********************************************************************** |
| 465 | * Function - LinkControlResponseMessage() |
| 466 | * |
| 467 | * Description - This function handles the Link response packets. |
| 468 | * |
| 469 | * Parameters - Adapter : Pointer to the Adapter structure. |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 470 | * - pucBuffer: Starting address of Link response data. |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 471 | * |
| 472 | * Returns - None. |
| 473 | ***********************************************************************/ |
Kevin McKinney | 7a15b79 | 2012-10-18 22:40:08 -0400 | [diff] [blame] | 474 | void LinkControlResponseMessage(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 475 | { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 476 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "=====>"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 477 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 478 | if (*pucBuffer == LINK_UP_ACK) { |
| 479 | switch (*(pucBuffer+1)) { |
| 480 | case PHY_SYNC_ACHIVED: /* SYNCed UP */ |
| 481 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "PHY_SYNC_ACHIVED"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 482 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 483 | if (Adapter->LinkStatus == LINKUP_DONE) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 484 | beceem_protocol_reset(Adapter); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 485 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 486 | Adapter->usBestEffortQueueIndex = INVALID_QUEUE_INDEX; |
| 487 | Adapter->LinkStatus = PHY_SYNC_ACHIVED; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 488 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 489 | if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 490 | Adapter->DriverState = NO_NETWORK_ENTRY; |
| 491 | wake_up(&Adapter->LEDInfo.notify_led_event); |
| 492 | } |
| 493 | |
| 494 | LinkMessage(Adapter); |
| 495 | break; |
| 496 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 497 | case LINKUP_DONE: |
| 498 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "LINKUP_DONE"); |
| 499 | Adapter->LinkStatus = LINKUP_DONE; |
| 500 | Adapter->bPHSEnabled = *(pucBuffer+3); |
| 501 | Adapter->bETHCSEnabled = *(pucBuffer+4) & ETH_CS_MASK; |
| 502 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "PHS Support Status Received In LinkUp Ack : %x\n", Adapter->bPHSEnabled); |
| 503 | |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 504 | if ((false == Adapter->bShutStatus) && (false == Adapter->IdleMode)) { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 505 | if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { |
| 506 | Adapter->DriverState = NORMAL_OPERATION; |
| 507 | wake_up(&Adapter->LEDInfo.notify_led_event); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 508 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 509 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 510 | LinkMessage(Adapter); |
| 511 | break; |
| 512 | |
| 513 | case WAIT_FOR_SYNC: |
| 514 | /* |
| 515 | * Driver to ignore the DREG_RECEIVED |
| 516 | * WiMAX Application should handle this Message |
| 517 | */ |
| 518 | /* Adapter->liTimeSinceLastNetEntry = 0; */ |
| 519 | Adapter->LinkUpStatus = 0; |
| 520 | Adapter->LinkStatus = 0; |
| 521 | Adapter->usBestEffortQueueIndex = INVALID_QUEUE_INDEX; |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 522 | Adapter->bTriedToWakeUpFromlowPowerMode = false; |
| 523 | Adapter->IdleMode = false; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 524 | beceem_protocol_reset(Adapter); |
| 525 | |
| 526 | break; |
| 527 | case LINK_SHUTDOWN_REQ_FROM_FIRMWARE: |
| 528 | case COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW: |
| 529 | { |
| 530 | HandleShutDownModeRequest(Adapter, pucBuffer); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 531 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 532 | break; |
| 533 | default: |
| 534 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "default case:LinkResponse %x", *(pucBuffer + 1)); |
| 535 | break; |
| 536 | } |
| 537 | } else if (SET_MAC_ADDRESS_RESPONSE == *pucBuffer) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 538 | PUCHAR puMacAddr = (pucBuffer + 1); |
Robin Schroer | fe83073 | 2014-06-16 13:01:46 +0200 | [diff] [blame] | 539 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 540 | Adapter->LinkStatus = SYNC_UP_REQUEST; |
| 541 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "MAC address response, sending SYNC_UP"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 542 | LinkMessage(Adapter); |
| 543 | memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); |
| 544 | } |
Kevin McKinney | a8a1cdd | 2011-10-07 18:50:10 -0400 | [diff] [blame] | 545 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "%s <=====", __func__); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 546 | } |
| 547 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 548 | void SendIdleModeResponse(struct bcm_mini_adapter *Adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 549 | { |
Kevin McKinney | 7af14134 | 2012-10-18 22:40:13 -0400 | [diff] [blame] | 550 | int status = 0, NVMAccess = 0, lowPwrAbortMsg = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 551 | struct timeval tv; |
Kevin McKinney | 2610c7a | 2012-05-26 12:05:08 -0400 | [diff] [blame] | 552 | struct bcm_link_request stIdleResponse = {{0} }; |
Robin Schroer | fe83073 | 2014-06-16 13:01:46 +0200 | [diff] [blame] | 553 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 554 | memset(&tv, 0, sizeof(tv)); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 555 | stIdleResponse.Leader.Status = IDLE_MESSAGE; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 556 | stIdleResponse.Leader.PLength = IDLE_MODE_PAYLOAD_LENGTH; |
| 557 | stIdleResponse.szData[0] = GO_TO_IDLE_MODE_PAYLOAD; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 558 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, " ============>"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 559 | |
| 560 | /********************************* |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 561 | *down_trylock - |
| 562 | * if [ semaphore is available ] |
| 563 | * acquire semaphone and return value 0 ; |
| 564 | * else |
| 565 | * return non-zero value ; |
| 566 | * |
| 567 | ***********************************/ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 568 | |
| 569 | NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 570 | lowPwrAbortMsg = down_trylock(&Adapter->LowPowerModeSync); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 571 | |
| 572 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 573 | if ((NVMAccess || lowPwrAbortMsg || atomic_read(&Adapter->TotalPacketCount)) && |
| 574 | (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)) { |
| 575 | |
| 576 | if (!NVMAccess) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 577 | up(&Adapter->NVMRdmWrmLock); |
| 578 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 579 | if (!lowPwrAbortMsg) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 580 | up(&Adapter->LowPowerModeSync); |
| 581 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 582 | stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE; /* NACK- device access is going on. */ |
| 583 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "HOST IS NACKING Idle mode To F/W!!!!!!!!"); |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 584 | Adapter->bPreparingForLowPowerMode = false; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 585 | } else { |
| 586 | stIdleResponse.szData[1] = TARGET_CAN_GO_TO_IDLE_MODE; /* 2; Idle ACK */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 587 | Adapter->StatisticsPointer = 0; |
| 588 | |
| 589 | /* Wait for the LED to TURN OFF before sending ACK response */ |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 590 | if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { |
Kevin McKinney | 7af14134 | 2012-10-18 22:40:13 -0400 | [diff] [blame] | 591 | int iRetVal = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 592 | |
| 593 | /* Wake the LED Thread with IDLEMODE_ENTER State */ |
| 594 | Adapter->DriverState = LOWPOWER_MODE_ENTER; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 595 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "LED Thread is Running..Hence Setting LED Event as IDLEMODE_ENTER jiffies:%ld", jiffies); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 596 | wake_up(&Adapter->LEDInfo.notify_led_event); |
| 597 | |
| 598 | /* Wait for 1 SEC for LED to OFF */ |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 599 | iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent, Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000)); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 600 | |
| 601 | /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */ |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 602 | if (iRetVal <= 0) { |
| 603 | stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE; /* NACK- device access is going on. */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 604 | Adapter->DriverState = NORMAL_OPERATION; |
| 605 | wake_up(&Adapter->LEDInfo.notify_led_event); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 606 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "NACKING Idle mode as time out happen from LED side!!!!!!!!"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 607 | } |
| 608 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 609 | |
| 610 | if (stIdleResponse.szData[1] == TARGET_CAN_GO_TO_IDLE_MODE) { |
| 611 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "ACKING IDLE MODE !!!!!!!!!"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 612 | down(&Adapter->rdmwrmsync); |
| 613 | Adapter->bPreparingForLowPowerMode = TRUE; |
| 614 | up(&Adapter->rdmwrmsync); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 615 | /* Killing all URBS. */ |
| 616 | if (Adapter->bDoSuspend == TRUE) |
Kevin McKinney | d6861cf | 2012-11-01 23:42:21 -0400 | [diff] [blame] | 617 | Bcm_kill_all_URBs((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter)); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 618 | } else { |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 619 | Adapter->bPreparingForLowPowerMode = false; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 620 | } |
| 621 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 622 | if (!NVMAccess) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 623 | up(&Adapter->NVMRdmWrmLock); |
| 624 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 625 | if (!lowPwrAbortMsg) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 626 | up(&Adapter->LowPowerModeSync); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 627 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 628 | |
| 629 | status = CopyBufferToControlPacket(Adapter, &stIdleResponse); |
Robin Schroer | 28c520a | 2014-06-16 13:01:47 +0200 | [diff] [blame] | 630 | if (status != STATUS_SUCCESS) { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 631 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "fail to send the Idle mode Request\n"); |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 632 | Adapter->bPreparingForLowPowerMode = false; |
Kevin McKinney | d6861cf | 2012-11-01 23:42:21 -0400 | [diff] [blame] | 633 | StartInterruptUrb((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter)); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 634 | } |
| 635 | do_gettimeofday(&tv); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 636 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "IdleMode Msg submitter to Q :%ld ms", tv.tv_sec * 1000 + tv.tv_usec / 1000); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 637 | } |
| 638 | |
| 639 | /****************************************************************** |
| 640 | * Function - DumpPackInfo() |
| 641 | * |
| 642 | * Description - This function dumps the all Queue(PackInfo[]) details. |
| 643 | * |
| 644 | * Parameters - Adapter: Pointer to the Adapter structure. |
| 645 | * |
| 646 | * Returns - None. |
| 647 | *******************************************************************/ |
Kevin McKinney | 7a15b79 | 2012-10-18 22:40:08 -0400 | [diff] [blame] | 648 | void DumpPackInfo(struct bcm_mini_adapter *Adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 649 | { |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 650 | unsigned int uiLoopIndex = 0; |
| 651 | unsigned int uiIndex = 0; |
| 652 | unsigned int uiClsfrIndex = 0; |
Kevin McKinney | 92562ae | 2012-05-26 12:05:03 -0400 | [diff] [blame] | 653 | struct bcm_classifier_rule *pstClassifierEntry = NULL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 654 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 655 | for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) { |
| 656 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "*********** Showing Details Of Queue %d***** ******", uiLoopIndex); |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 657 | if (false == Adapter->PackInfo[uiLoopIndex].bValid) { |
| 658 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bValid is false for %X index\n", uiLoopIndex); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 659 | continue; |
| 660 | } |
| 661 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 662 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, " Dumping SF Rule Entry For SFID %lX\n", Adapter->PackInfo[uiLoopIndex].ulSFID); |
| 663 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, " ucDirection %X\n", Adapter->PackInfo[uiLoopIndex].ucDirection); |
| 664 | |
| 665 | if (Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) |
| 666 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Ipv6 Service Flow\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 667 | else |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 668 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Ipv4 Service Flow\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 669 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 670 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "SF Traffic Priority %X\n", Adapter->PackInfo[uiLoopIndex].u8TrafficPriority); |
| 671 | |
| 672 | for (uiClsfrIndex = 0; uiClsfrIndex < MAX_CLASSIFIERS; uiClsfrIndex++) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 673 | pstClassifierEntry = &Adapter->astClassifierTable[uiClsfrIndex]; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 674 | if (!pstClassifierEntry->bUsed) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 675 | continue; |
| 676 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 677 | if (pstClassifierEntry->ulSFID != Adapter->PackInfo[uiLoopIndex].ulSFID) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 678 | continue; |
| 679 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 680 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X Classifier Rule ID : %X\n", uiClsfrIndex, pstClassifierEntry->uiClassifierRuleIndex); |
| 681 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X usVCID_Value : %X\n", uiClsfrIndex, pstClassifierEntry->usVCID_Value); |
| 682 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bProtocolValid : %X\n", uiClsfrIndex, pstClassifierEntry->bProtocolValid); |
| 683 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bTOSValid : %X\n", uiClsfrIndex, pstClassifierEntry->bTOSValid); |
| 684 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bDestIpValid : %X\n", uiClsfrIndex, pstClassifierEntry->bDestIpValid); |
| 685 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bSrcIpValid : %X\n", uiClsfrIndex, pstClassifierEntry->bSrcIpValid); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 686 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 687 | for (uiIndex = 0; uiIndex < MAX_PORT_RANGE; uiIndex++) { |
| 688 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusSrcPortRangeLo:%X\n", pstClassifierEntry->usSrcPortRangeLo[uiIndex]); |
| 689 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusSrcPortRangeHi:%X\n", pstClassifierEntry->usSrcPortRangeHi[uiIndex]); |
| 690 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusDestPortRangeLo:%X\n", pstClassifierEntry->usDestPortRangeLo[uiIndex]); |
| 691 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusDestPortRangeHi:%X\n", pstClassifierEntry->usDestPortRangeHi[uiIndex]); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 692 | } |
| 693 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 694 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tucIPSourceAddressLength : 0x%x\n", pstClassifierEntry->ucIPSourceAddressLength); |
| 695 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tucIPDestinationAddressLength : 0x%x\n", pstClassifierEntry->ucIPDestinationAddressLength); |
| 696 | for (uiIndex = 0; uiIndex < pstClassifierEntry->ucIPSourceAddressLength; uiIndex++) { |
| 697 | if (Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) { |
| 698 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulSrcIpAddr :\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 699 | DumpIpv6Address(pstClassifierEntry->stSrcIpAddress.ulIpv6Addr); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 700 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulSrcIpMask :\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 701 | DumpIpv6Address(pstClassifierEntry->stSrcIpAddress.ulIpv6Mask); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 702 | } else { |
| 703 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulSrcIpAddr:%lX\n", pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[uiIndex]); |
| 704 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulSrcIpMask:%lX\n", pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[uiIndex]); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 705 | } |
| 706 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 707 | |
| 708 | for (uiIndex = 0; uiIndex < pstClassifierEntry->ucIPDestinationAddressLength; uiIndex++) { |
| 709 | if (Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) { |
| 710 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulDestIpAddr :\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 711 | DumpIpv6Address(pstClassifierEntry->stDestIpAddress.ulIpv6Addr); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 712 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulDestIpMask :\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 713 | DumpIpv6Address(pstClassifierEntry->stDestIpAddress.ulIpv6Mask); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 714 | } else { |
| 715 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulDestIpAddr:%lX\n", pstClassifierEntry->stDestIpAddress.ulIpv4Addr[uiIndex]); |
| 716 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulDestIpMask:%lX\n", pstClassifierEntry->stDestIpAddress.ulIpv4Mask[uiIndex]); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 717 | } |
| 718 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 719 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tucProtocol:0x%X\n", pstClassifierEntry->ucProtocol[0]); |
| 720 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tu8ClassifierRulePriority:%X\n", pstClassifierEntry->u8ClassifierRulePriority); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 721 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 722 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ulSFID:%lX\n", Adapter->PackInfo[uiLoopIndex].ulSFID); |
| 723 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "usVCID_Value:%X\n", Adapter->PackInfo[uiLoopIndex].usVCID_Value); |
| 724 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "PhsEnabled: 0x%X\n", Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled); |
| 725 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiThreshold:%X\n", Adapter->PackInfo[uiLoopIndex].uiThreshold); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 726 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 727 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bValid:%X\n", Adapter->PackInfo[uiLoopIndex].bValid); |
| 728 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bActive:%X\n", Adapter->PackInfo[uiLoopIndex].bActive); |
| 729 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ActivateReqSent: %x", Adapter->PackInfo[uiLoopIndex].bActivateRequestSent); |
| 730 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "u8QueueType:%X\n", Adapter->PackInfo[uiLoopIndex].u8QueueType); |
| 731 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxBucketSize:%X\n", Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize); |
| 732 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiPerSFTxResourceCount:%X\n", atomic_read(&Adapter->PackInfo[uiLoopIndex].uiPerSFTxResourceCount)); |
| 733 | /* DumpDebug(DUMP_INFO,("bCSSupport:%X\n",Adapter->PackInfo[uiLoopIndex].bCSSupport)); */ |
| 734 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "CurrQueueDepthOnTarget: %x\n", Adapter->PackInfo[uiLoopIndex].uiCurrentQueueDepthOnTarget); |
| 735 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentBytesOnHost:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentBytesOnHost); |
| 736 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentPacketsOnHost:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentPacketsOnHost); |
| 737 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiDroppedCountBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiDroppedCountBytes); |
| 738 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiDroppedCountPackets:%X\n", Adapter->PackInfo[uiLoopIndex].uiDroppedCountPackets); |
| 739 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiSentBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiSentBytes); |
| 740 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiSentPackets:%X\n", Adapter->PackInfo[uiLoopIndex].uiSentPackets); |
| 741 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentDrainRate:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentDrainRate); |
| 742 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiThisPeriodSentBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiThisPeriodSentBytes); |
| 743 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "liDrainCalculated:%llX\n", Adapter->PackInfo[uiLoopIndex].liDrainCalculated); |
| 744 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentTokenCount:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentTokenCount); |
| 745 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "liLastUpdateTokenAt:%llX\n", Adapter->PackInfo[uiLoopIndex].liLastUpdateTokenAt); |
| 746 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxAllowedRate:%X\n", Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate); |
| 747 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiPendedLast:%X\n", Adapter->PackInfo[uiLoopIndex].uiPendedLast); |
| 748 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "NumOfPacketsSent:%X\n", Adapter->PackInfo[uiLoopIndex].NumOfPacketsSent); |
| 749 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Direction: %x\n", Adapter->PackInfo[uiLoopIndex].ucDirection); |
| 750 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "CID: %x\n", Adapter->PackInfo[uiLoopIndex].usCID); |
| 751 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ProtocolValid: %x\n", Adapter->PackInfo[uiLoopIndex].bProtocolValid); |
| 752 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "TOSValid: %x\n", Adapter->PackInfo[uiLoopIndex].bTOSValid); |
| 753 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "DestIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bDestIpValid); |
| 754 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "SrcIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bSrcIpValid); |
| 755 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ActiveSet: %x\n", Adapter->PackInfo[uiLoopIndex].bActiveSet); |
| 756 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AdmittedSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAdmittedSet); |
| 757 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AuthzSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAuthorizedSet); |
| 758 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ClassifyPrority: %x\n", Adapter->PackInfo[uiLoopIndex].bClassifierPriority); |
| 759 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxLatency: %x\n", Adapter->PackInfo[uiLoopIndex].uiMaxLatency); |
Andy Shevchenko | bcb6ef6 | 2012-08-02 19:05:44 +0300 | [diff] [blame] | 760 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, |
| 761 | DBG_LVL_ALL, "ServiceClassName: %*ph\n", |
| 762 | 4, Adapter->PackInfo[uiLoopIndex]. |
| 763 | ucServiceClassName); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 764 | /* BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bHeaderSuppressionEnabled :%X\n", Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled); |
| 765 | * BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalTxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalTxBytes); |
| 766 | * BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalRxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalRxBytes); |
| 767 | * DumpDebug(DUMP_INFO,(" uiRanOutOfResCount:%X\n",Adapter->PackInfo[uiLoopIndex].uiRanOutOfResCount)); |
| 768 | */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 769 | } |
| 770 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 771 | for (uiLoopIndex = 0; uiLoopIndex < MIBS_MAX_HIST_ENTRIES; uiLoopIndex++) |
| 772 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Adapter->aRxPktSizeHist[%x] = %x\n", uiLoopIndex, Adapter->aRxPktSizeHist[uiLoopIndex]); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 773 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 774 | for (uiLoopIndex = 0; uiLoopIndex < MIBS_MAX_HIST_ENTRIES; uiLoopIndex++) |
| 775 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Adapter->aTxPktSizeHist[%x] = %x\n", uiLoopIndex, Adapter->aTxPktSizeHist[uiLoopIndex]); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 776 | } |
| 777 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 778 | int reset_card_proc(struct bcm_mini_adapter *ps_adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 779 | { |
| 780 | int retval = STATUS_SUCCESS; |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 781 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Kevin McKinney | d6861cf | 2012-11-01 23:42:21 -0400 | [diff] [blame] | 782 | struct bcm_interface_adapter *psIntfAdapter = NULL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 783 | unsigned int value = 0, uiResetValue = 0; |
Kevin McKinney | 41c7b7c | 2011-11-06 09:40:11 -0500 | [diff] [blame] | 784 | int bytes; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 785 | |
Kevin McKinney | d6861cf | 2012-11-01 23:42:21 -0400 | [diff] [blame] | 786 | psIntfAdapter = ((struct bcm_interface_adapter *)(ps_adapter->pvInterfaceAdapter)); |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 787 | ps_adapter->bDDRInitDone = false; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 788 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 789 | if (ps_adapter->chip_id >= T3LPB) { |
| 790 | /* SYS_CFG register is write protected hence for modifying this reg value, it should be read twice before */ |
| 791 | rdmalt(ps_adapter, SYS_CFG, &value, sizeof(value)); |
| 792 | rdmalt(ps_adapter, SYS_CFG, &value, sizeof(value)); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 793 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 794 | /* making bit[6...5] same as was before f/w download. this setting force the h/w to */ |
| 795 | /* re-populated the SP RAM area with the string descriptor. */ |
| 796 | value = value | (ps_adapter->syscfgBefFwDld & 0x00000060); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 797 | wrmalt(ps_adapter, SYS_CFG, &value, sizeof(value)); |
| 798 | } |
| 799 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 800 | /* killing all submitted URBs. */ |
| 801 | psIntfAdapter->psAdapter->StopAllXaction = TRUE; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 802 | Bcm_kill_all_URBs(psIntfAdapter); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 803 | /* Reset the UMA-B Device */ |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 804 | if (ps_adapter->chip_id >= T3LPB) { |
Masanari Iida | 73e2918 | 2012-04-06 23:33:52 +0900 | [diff] [blame] | 805 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Resetting UMA-B\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 806 | retval = usb_reset_device(psIntfAdapter->udev); |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 807 | psIntfAdapter->psAdapter->StopAllXaction = false; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 808 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 809 | if (retval != STATUS_SUCCESS) { |
| 810 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reset failed with ret value :%d", retval); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 811 | goto err_exit; |
| 812 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 813 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 814 | if (ps_adapter->chip_id == BCS220_2 || |
| 815 | ps_adapter->chip_id == BCS220_2BC || |
| 816 | ps_adapter->chip_id == BCS250_BC || |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 817 | ps_adapter->chip_id == BCS220_3) { |
| 818 | |
Kevin McKinney | 41c7b7c | 2011-11-06 09:40:11 -0500 | [diff] [blame] | 819 | bytes = rdmalt(ps_adapter, HPM_CONFIG_LDO145, &value, sizeof(value)); |
| 820 | if (bytes < 0) { |
| 821 | retval = bytes; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 822 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "read failed with status :%d", retval); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 823 | goto err_exit; |
| 824 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 825 | /* setting 0th bit */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 826 | value |= (1<<0); |
| 827 | retval = wrmalt(ps_adapter, HPM_CONFIG_LDO145, &value, sizeof(value)); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 828 | if (retval < 0) { |
| 829 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 830 | goto err_exit; |
| 831 | } |
| 832 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 833 | } else { |
Kevin McKinney | 41c7b7c | 2011-11-06 09:40:11 -0500 | [diff] [blame] | 834 | bytes = rdmalt(ps_adapter, 0x0f007018, &value, sizeof(value)); |
| 835 | if (bytes < 0) { |
| 836 | retval = bytes; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 837 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "read failed with status :%d", retval); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 838 | goto err_exit; |
| 839 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 840 | value &= (~(1<<16)); |
| 841 | retval = wrmalt(ps_adapter, 0x0f007018, &value, sizeof(value)); |
| 842 | if (retval < 0) { |
| 843 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 844 | goto err_exit; |
| 845 | } |
| 846 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 847 | /* Toggling the GPIO 8, 9 */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 848 | value = 0; |
| 849 | retval = wrmalt(ps_adapter, GPIO_OUTPUT_REGISTER, &value, sizeof(value)); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 850 | if (retval < 0) { |
| 851 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 852 | goto err_exit; |
| 853 | } |
| 854 | value = 0x300; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 855 | retval = wrmalt(ps_adapter, GPIO_MODE_REGISTER, &value, sizeof(value)); |
| 856 | if (retval < 0) { |
| 857 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 858 | goto err_exit; |
| 859 | } |
| 860 | mdelay(50); |
| 861 | } |
| 862 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 863 | /* ps_adapter->downloadDDR = false; */ |
| 864 | if (ps_adapter->bFlashBoot) { |
| 865 | /* In flash boot mode MIPS state register has reverse polarity. |
| 866 | * So just or with setting bit 30. |
| 867 | * Make the MIPS in Reset state. |
| 868 | */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 869 | rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &uiResetValue, sizeof(uiResetValue)); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 870 | uiResetValue |= (1<<30); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 871 | wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &uiResetValue, sizeof(uiResetValue)); |
| 872 | } |
| 873 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 874 | if (ps_adapter->chip_id >= T3LPB) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 875 | uiResetValue = 0; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 876 | /* |
| 877 | * WA for SYSConfig Issue. |
| 878 | * Read SYSCFG Twice to make it writable. |
| 879 | */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 880 | rdmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue)); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 881 | if (uiResetValue & (1<<4)) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 882 | uiResetValue = 0; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 883 | rdmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue)); /* 2nd read to make it writable. */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 884 | uiResetValue &= (~(1<<4)); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 885 | wrmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue)); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 886 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 887 | } |
| 888 | uiResetValue = 0; |
| 889 | wrmalt(ps_adapter, 0x0f01186c, &uiResetValue, sizeof(uiResetValue)); |
| 890 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 891 | err_exit: |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 892 | psIntfAdapter->psAdapter->StopAllXaction = false; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 893 | return retval; |
| 894 | } |
| 895 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 896 | int run_card_proc(struct bcm_mini_adapter *ps_adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 897 | { |
Kevin McKinney | 41c7b7c | 2011-11-06 09:40:11 -0500 | [diff] [blame] | 898 | int status = STATUS_SUCCESS; |
| 899 | int bytes; |
| 900 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 901 | unsigned int value = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 902 | { |
Kevin McKinney | 41c7b7c | 2011-11-06 09:40:11 -0500 | [diff] [blame] | 903 | bytes = rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)); |
| 904 | if (bytes < 0) { |
| 905 | status = bytes; |
Kevin McKinney | a8a1cdd | 2011-10-07 18:50:10 -0400 | [diff] [blame] | 906 | BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%d\n", __func__, __LINE__); |
Kevin McKinney | 41c7b7c | 2011-11-06 09:40:11 -0500 | [diff] [blame] | 907 | return status; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 908 | } |
| 909 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 910 | if (ps_adapter->bFlashBoot) |
| 911 | value &= (~(1<<30)); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 912 | else |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 913 | value |= (1<<30); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 914 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 915 | if (wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)) < 0) { |
Kevin McKinney | a8a1cdd | 2011-10-07 18:50:10 -0400 | [diff] [blame] | 916 | BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%d\n", __func__, __LINE__); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 917 | return STATUS_FAILURE; |
| 918 | } |
| 919 | } |
Kevin McKinney | 41c7b7c | 2011-11-06 09:40:11 -0500 | [diff] [blame] | 920 | return status; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 921 | } |
| 922 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 923 | int InitCardAndDownloadFirmware(struct bcm_mini_adapter *ps_adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 924 | { |
Dan Carpenter | 2e31613 | 2010-11-13 11:24:22 +0300 | [diff] [blame] | 925 | int status; |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 926 | unsigned int value = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 927 | /* |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 928 | * Create the threads first and then download the |
| 929 | * Firm/DDR Settings.. |
| 930 | */ |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 931 | status = create_worker_threads(ps_adapter); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 932 | if (status < 0) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 933 | return status; |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 934 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 935 | status = bcm_parse_target_params(ps_adapter); |
| 936 | if (status) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 937 | return status; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 938 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 939 | if (ps_adapter->chip_id >= T3LPB) { |
| 940 | rdmalt(ps_adapter, SYS_CFG, &value, sizeof(value)); |
| 941 | ps_adapter->syscfgBefFwDld = value; |
| 942 | |
| 943 | if ((value & 0x60) == 0) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 944 | ps_adapter->bFlashBoot = TRUE; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 945 | } |
| 946 | |
| 947 | reset_card_proc(ps_adapter); |
| 948 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 949 | /* Initializing the NVM. */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 950 | BcmInitNVM(ps_adapter); |
| 951 | status = ddr_init(ps_adapter); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 952 | if (status) { |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 953 | pr_err(DRV_NAME "ddr_init Failed\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 954 | return status; |
| 955 | } |
| 956 | |
| 957 | /* Download cfg file */ |
| 958 | status = buffDnldVerify(ps_adapter, |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 959 | (PUCHAR)ps_adapter->pstargetparams, |
Kevin McKinney | c818233 | 2012-12-17 17:35:20 -0500 | [diff] [blame] | 960 | sizeof(struct bcm_target_params), |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 961 | CONFIG_BEGIN_ADDR); |
| 962 | if (status) { |
| 963 | BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Error downloading CFG file"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 964 | goto OUT; |
| 965 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 966 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 967 | if (register_networkdev(ps_adapter)) { |
| 968 | BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Netdevice failed. Cleanup needs to be performed."); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 969 | return -EIO; |
| 970 | } |
| 971 | |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 972 | if (false == ps_adapter->AutoFirmDld) { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 973 | BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoFirmDld Disabled in CFG File..\n"); |
| 974 | /* If Auto f/w download is disable, register the control interface, */ |
| 975 | /* register the control interface after the mailbox. */ |
| 976 | if (register_control_device_interface(ps_adapter) < 0) { |
| 977 | BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Control Device failed. Cleanup needs to be performed."); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 978 | return -EIO; |
| 979 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 980 | return STATUS_SUCCESS; |
| 981 | } |
| 982 | |
| 983 | /* |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 984 | * Do the LED Settings here. It will be used by the Firmware Download |
| 985 | * Thread. |
| 986 | */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 987 | |
| 988 | /* |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 989 | * 1. If the LED Settings fails, do not stop and do the Firmware download. |
| 990 | * 2. This init would happened only if the cfg file is present, else |
| 991 | * call from the ioctl context. |
| 992 | */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 993 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 994 | status = InitLedSettings(ps_adapter); |
| 995 | if (status) { |
| 996 | BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_PRINTK, 0, 0, "INIT LED FAILED\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 997 | return status; |
| 998 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 999 | |
| 1000 | if (ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1001 | ps_adapter->DriverState = DRIVER_INIT; |
| 1002 | wake_up(&ps_adapter->LEDInfo.notify_led_event); |
| 1003 | } |
| 1004 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1005 | if (ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1006 | ps_adapter->DriverState = FW_DOWNLOAD; |
| 1007 | wake_up(&ps_adapter->LEDInfo.notify_led_event); |
| 1008 | } |
| 1009 | |
| 1010 | value = 0; |
| 1011 | wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value)); |
| 1012 | wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value)); |
| 1013 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1014 | if (ps_adapter->eNVMType == NVM_FLASH) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1015 | status = PropagateCalParamsFromFlashToMemory(ps_adapter); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1016 | if (status) { |
| 1017 | BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Propagation of Cal param failed .."); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1018 | goto OUT; |
| 1019 | } |
| 1020 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1021 | |
| 1022 | /* Download Firmare */ |
Kevin McKinney | d491061 | 2011-10-07 18:50:12 -0400 | [diff] [blame] | 1023 | status = BcmFileDownload(ps_adapter, BIN_FILE, FIRMWARE_BEGIN_ADDR); |
| 1024 | if (status != 0) { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1025 | BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Firmware File is present...\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1026 | goto OUT; |
| 1027 | } |
| 1028 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1029 | status = run_card_proc(ps_adapter); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1030 | if (status) { |
| 1031 | BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "run_card_proc Failed\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1032 | goto OUT; |
| 1033 | } |
| 1034 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1035 | ps_adapter->fw_download_done = TRUE; |
| 1036 | mdelay(10); |
| 1037 | |
| 1038 | OUT: |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1039 | if (ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1040 | ps_adapter->DriverState = FW_DOWNLOAD_DONE; |
| 1041 | wake_up(&ps_adapter->LEDInfo.notify_led_event); |
| 1042 | } |
| 1043 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1044 | return status; |
| 1045 | } |
| 1046 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1047 | static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1048 | { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1049 | struct file *flp = NULL; |
Jesper Juhl | 3701bef | 2010-11-10 21:31:38 +0100 | [diff] [blame] | 1050 | char *buff; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1051 | int len = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1052 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1053 | buff = kmalloc(BUFFER_1K, GFP_KERNEL); |
| 1054 | if (!buff) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1055 | return -ENOMEM; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1056 | |
Kevin McKinney | c818233 | 2012-12-17 17:35:20 -0500 | [diff] [blame] | 1057 | Adapter->pstargetparams = kmalloc(sizeof(struct bcm_target_params), GFP_KERNEL); |
Kevin McKinney | 9d4f1d0 | 2011-10-07 18:50:11 -0400 | [diff] [blame] | 1058 | if (Adapter->pstargetparams == NULL) { |
Stephen Hemminger | 082e889 | 2010-11-01 09:35:21 -0400 | [diff] [blame] | 1059 | kfree(buff); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1060 | return -ENOMEM; |
| 1061 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1062 | |
| 1063 | flp = open_firmware_file(Adapter, CFG_FILE); |
| 1064 | if (!flp) { |
| 1065 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "NOT ABLE TO OPEN THE %s FILE\n", CFG_FILE); |
Stephen Hemminger | 082e889 | 2010-11-01 09:35:21 -0400 | [diff] [blame] | 1066 | kfree(buff); |
| 1067 | kfree(Adapter->pstargetparams); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1068 | Adapter->pstargetparams = NULL; |
| 1069 | return -ENOENT; |
| 1070 | } |
Al Viro | 32aecdd | 2012-07-22 21:02:01 +0400 | [diff] [blame] | 1071 | len = kernel_read(flp, 0, buff, BUFFER_1K); |
| 1072 | filp_close(flp, NULL); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1073 | |
Kevin McKinney | c818233 | 2012-12-17 17:35:20 -0500 | [diff] [blame] | 1074 | if (len != sizeof(struct bcm_target_params)) { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1075 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Mismatch in Target Param Structure!\n"); |
Stephen Hemminger | 082e889 | 2010-11-01 09:35:21 -0400 | [diff] [blame] | 1076 | kfree(buff); |
| 1077 | kfree(Adapter->pstargetparams); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1078 | Adapter->pstargetparams = NULL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1079 | return -ENOENT; |
| 1080 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1081 | |
| 1082 | /* Check for autolink in config params */ |
| 1083 | /* |
| 1084 | * Values in Adapter->pstargetparams are in network byte order |
| 1085 | */ |
Kevin McKinney | c818233 | 2012-12-17 17:35:20 -0500 | [diff] [blame] | 1086 | memcpy(Adapter->pstargetparams, buff, sizeof(struct bcm_target_params)); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1087 | kfree(buff); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1088 | beceem_parse_target_struct(Adapter); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1089 | return STATUS_SUCCESS; |
| 1090 | } |
| 1091 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1092 | void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1093 | { |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1094 | unsigned int uiHostDrvrCfg6 = 0, uiEEPROMFlag = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1095 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1096 | if (ntohl(Adapter->pstargetparams->m_u32PhyParameter2) & AUTO_SYNC_DISABLE) { |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 1097 | pr_info(DRV_NAME ": AutoSyncup is Disabled\n"); |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1098 | Adapter->AutoSyncup = false; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1099 | } else { |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 1100 | pr_info(DRV_NAME ": AutoSyncup is Enabled\n"); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1101 | Adapter->AutoSyncup = TRUE; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1102 | } |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 1103 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1104 | if (ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_LINKUP_ENABLE) { |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 1105 | pr_info(DRV_NAME ": Enabling autolink up"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1106 | Adapter->AutoLinkUp = TRUE; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1107 | } else { |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 1108 | pr_info(DRV_NAME ": Disabling autolink up"); |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1109 | Adapter->AutoLinkUp = false; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1110 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1111 | /* Setting the DDR Setting.. */ |
| 1112 | Adapter->DDRSetting = (ntohl(Adapter->pstargetparams->HostDrvrConfig6) >> 8)&0x0F; |
| 1113 | Adapter->ulPowerSaveMode = (ntohl(Adapter->pstargetparams->HostDrvrConfig6)>>12)&0x0F; |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 1114 | pr_info(DRV_NAME ": DDR Setting: %x\n", Adapter->DDRSetting); |
| 1115 | pr_info(DRV_NAME ": Power Save Mode: %lx\n", Adapter->ulPowerSaveMode); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1116 | if (ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_FIRM_DOWNLOAD) { |
| 1117 | pr_info(DRV_NAME ": Enabling Auto Firmware Download\n"); |
| 1118 | Adapter->AutoFirmDld = TRUE; |
| 1119 | } else { |
| 1120 | pr_info(DRV_NAME ": Disabling Auto Firmware Download\n"); |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1121 | Adapter->AutoFirmDld = false; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1122 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1123 | uiHostDrvrCfg6 = ntohl(Adapter->pstargetparams->HostDrvrConfig6); |
| 1124 | Adapter->bMipsConfig = (uiHostDrvrCfg6>>20)&0x01; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1125 | pr_info(DRV_NAME ": MIPSConfig : 0x%X\n", Adapter->bMipsConfig); |
| 1126 | /* used for backward compatibility. */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1127 | Adapter->bDPLLConfig = (uiHostDrvrCfg6>>19)&0x01; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1128 | Adapter->PmuMode = (uiHostDrvrCfg6 >> 24) & 0x03; |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 1129 | pr_info(DRV_NAME ": PMU MODE: %x", Adapter->PmuMode); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1130 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1131 | if ((uiHostDrvrCfg6 >> HOST_BUS_SUSPEND_BIT) & (0x01)) { |
| 1132 | Adapter->bDoSuspend = TRUE; |
| 1133 | pr_info(DRV_NAME ": Making DoSuspend TRUE as per configFile"); |
| 1134 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1135 | |
| 1136 | uiEEPROMFlag = ntohl(Adapter->pstargetparams->m_u32EEPROMFlag); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1137 | pr_info(DRV_NAME ": uiEEPROMFlag : 0x%X\n", uiEEPROMFlag); |
Kevin McKinney | af72c61 | 2012-12-21 15:10:36 -0500 | [diff] [blame] | 1138 | Adapter->eNVMType = (enum bcm_nvm_type)((uiEEPROMFlag>>4)&0x3); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1139 | Adapter->bStatusWrite = (uiEEPROMFlag>>6)&0x1; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1140 | Adapter->uiSectorSizeInCFG = 1024*(0xFFFF & ntohl(Adapter->pstargetparams->HostDrvrConfig4)); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1141 | Adapter->bSectorSizeOverride = (bool) ((ntohl(Adapter->pstargetparams->HostDrvrConfig4))>>16)&0x1; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1142 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1143 | if (ntohl(Adapter->pstargetparams->m_u32PowerSavingModeOptions) & 0x01) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1144 | Adapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE; |
Stephen Hemminger | 2d08748 | 2010-11-01 12:14:01 -0400 | [diff] [blame] | 1145 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1146 | if (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1147 | doPowerAutoCorrection(Adapter); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1148 | } |
| 1149 | |
Kevin McKinney | 7a15b79 | 2012-10-18 22:40:08 -0400 | [diff] [blame] | 1150 | static void doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1151 | { |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1152 | unsigned int reporting_mode; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1153 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1154 | reporting_mode = ntohl(psAdapter->pstargetparams->m_u32PowerSavingModeOptions) & 0x02; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1155 | psAdapter->bIsAutoCorrectEnabled = !((char)(psAdapter->ulPowerSaveMode >> 3) & 0x1); |
| 1156 | |
Andrey Utkin | 6b86609 | 2014-07-23 13:47:33 +0300 | [diff] [blame] | 1157 | if (reporting_mode) { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1158 | BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "can't do suspen/resume as reporting mode is enable"); |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1159 | psAdapter->bDoSuspend = false; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1160 | } |
| 1161 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1162 | if (psAdapter->bIsAutoCorrectEnabled && (psAdapter->chip_id >= T3LPB)) { |
| 1163 | /* If reporting mode is enable, switch PMU to PMC */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1164 | { |
| 1165 | psAdapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING; |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1166 | psAdapter->bDoSuspend = false; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1167 | } |
| 1168 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1169 | /* clearing space bit[15..12] */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1170 | psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl((0xF << 12))); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1171 | /* placing the power save mode option */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1172 | psAdapter->pstargetparams->HostDrvrConfig6 |= htonl((psAdapter->ulPowerSaveMode << 12)); |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1173 | } else if (psAdapter->bIsAutoCorrectEnabled == false) { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1174 | /* remove the autocorrect disable bit set before dumping. */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1175 | psAdapter->ulPowerSaveMode &= ~(1 << 3); |
| 1176 | psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl(1 << 15)); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1177 | BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Using Forced User Choice: %lx\n", psAdapter->ulPowerSaveMode); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1178 | } |
| 1179 | } |
Arnd Bergmann | 44a17eff | 2010-09-30 10:24:12 +0200 | [diff] [blame] | 1180 | |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1181 | static void convertEndian(unsigned char rwFlag, unsigned int *puiBuffer, unsigned int uiByteCount) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1182 | { |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1183 | unsigned int uiIndex = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1184 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1185 | if (RWM_WRITE == rwFlag) { |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1186 | for (uiIndex = 0; uiIndex < (uiByteCount/sizeof(unsigned int)); uiIndex++) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1187 | puiBuffer[uiIndex] = htonl(puiBuffer[uiIndex]); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1188 | } else { |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1189 | for (uiIndex = 0; uiIndex < (uiByteCount/sizeof(unsigned int)); uiIndex++) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1190 | puiBuffer[uiIndex] = ntohl(puiBuffer[uiIndex]); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1191 | } |
| 1192 | } |
| 1193 | |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1194 | int rdm(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, PCHAR pucBuff, size_t sSize) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1195 | { |
Greg Dietsche | c5274ab | 2011-06-13 13:11:47 -0500 | [diff] [blame] | 1196 | return Adapter->interface_rdm(Adapter->pvInterfaceAdapter, |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1197 | uiAddress, pucBuff, sSize); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1198 | } |
Greg Dietsche | c5274ab | 2011-06-13 13:11:47 -0500 | [diff] [blame] | 1199 | |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1200 | int wrm(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, PCHAR pucBuff, size_t sSize) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1201 | { |
| 1202 | int iRetVal; |
| 1203 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1204 | iRetVal = Adapter->interface_wrm(Adapter->pvInterfaceAdapter, |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1205 | uiAddress, pucBuff, sSize); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1206 | return iRetVal; |
| 1207 | } |
| 1208 | |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1209 | int wrmalt(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1210 | { |
| 1211 | convertEndian(RWM_WRITE, pucBuff, size); |
| 1212 | return wrm(Adapter, uiAddress, (PUCHAR)pucBuff, size); |
| 1213 | } |
| 1214 | |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1215 | int rdmalt(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1216 | { |
Kevin McKinney | 7af14134 | 2012-10-18 22:40:13 -0400 | [diff] [blame] | 1217 | int uiRetVal = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1218 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1219 | uiRetVal = rdm(Adapter, uiAddress, (PUCHAR)pucBuff, size); |
Kevin McKinney | b23f7f6 | 2012-10-18 22:40:09 -0400 | [diff] [blame] | 1220 | convertEndian(RWM_READ, (unsigned int *)pucBuff, size); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1221 | |
| 1222 | return uiRetVal; |
| 1223 | } |
| 1224 | |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1225 | int wrmWithLock(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, PCHAR pucBuff, size_t sSize) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1226 | { |
Kevin McKinney | 7af14134 | 2012-10-18 22:40:13 -0400 | [diff] [blame] | 1227 | int status = STATUS_SUCCESS; |
Robin Schroer | fe83073 | 2014-06-16 13:01:46 +0200 | [diff] [blame] | 1228 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1229 | down(&Adapter->rdmwrmsync); |
| 1230 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1231 | if ((Adapter->IdleMode == TRUE) || |
| 1232 | (Adapter->bShutStatus == TRUE) || |
| 1233 | (Adapter->bPreparingForLowPowerMode == TRUE)) { |
| 1234 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1235 | status = -EACCES; |
| 1236 | goto exit; |
| 1237 | } |
| 1238 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1239 | status = wrm(Adapter, uiAddress, pucBuff, sSize); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1240 | exit: |
| 1241 | up(&Adapter->rdmwrmsync); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1242 | return status; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1243 | } |
| 1244 | |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1245 | int wrmaltWithLock(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1246 | { |
| 1247 | int iRetVal = STATUS_SUCCESS; |
| 1248 | |
| 1249 | down(&Adapter->rdmwrmsync); |
| 1250 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1251 | if ((Adapter->IdleMode == TRUE) || |
| 1252 | (Adapter->bShutStatus == TRUE) || |
| 1253 | (Adapter->bPreparingForLowPowerMode == TRUE)) { |
| 1254 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1255 | iRetVal = -EACCES; |
| 1256 | goto exit; |
| 1257 | } |
| 1258 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1259 | iRetVal = wrmalt(Adapter, uiAddress, pucBuff, size); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1260 | exit: |
| 1261 | up(&Adapter->rdmwrmsync); |
| 1262 | return iRetVal; |
| 1263 | } |
| 1264 | |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1265 | int rdmaltWithLock(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1266 | { |
Kevin McKinney | 7af14134 | 2012-10-18 22:40:13 -0400 | [diff] [blame] | 1267 | int uiRetVal = STATUS_SUCCESS; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1268 | |
| 1269 | down(&Adapter->rdmwrmsync); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1270 | if ((Adapter->IdleMode == TRUE) || |
| 1271 | (Adapter->bShutStatus == TRUE) || |
| 1272 | (Adapter->bPreparingForLowPowerMode == TRUE)) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1273 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1274 | uiRetVal = -EACCES; |
| 1275 | goto exit; |
| 1276 | } |
| 1277 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1278 | uiRetVal = rdmalt(Adapter, uiAddress, pucBuff, size); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1279 | exit: |
| 1280 | up(&Adapter->rdmwrmsync); |
| 1281 | return uiRetVal; |
| 1282 | } |
| 1283 | |
Kevin McKinney | 7a15b79 | 2012-10-18 22:40:08 -0400 | [diff] [blame] | 1284 | static void HandleShutDownModeWakeup(struct bcm_mini_adapter *Adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1285 | { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1286 | int clear_abort_pattern = 0, Status = 0; |
Robin Schroer | fe83073 | 2014-06-16 13:01:46 +0200 | [diff] [blame] | 1287 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1288 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n"); |
| 1289 | /* target has woken up From Shut Down */ |
| 1290 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Clearing Shut Down Software abort pattern\n"); |
Kevin McKinney | b23f7f6 | 2012-10-18 22:40:09 -0400 | [diff] [blame] | 1291 | Status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC, (unsigned int *)&clear_abort_pattern, sizeof(clear_abort_pattern)); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1292 | if (Status) { |
| 1293 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "WRM to SW_ABORT_IDLEMODE_LOC failed with err:%d", Status); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1294 | return; |
| 1295 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1296 | |
| 1297 | if (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1298 | msleep(100); |
| 1299 | InterfaceHandleShutdownModeWakeup(Adapter); |
| 1300 | msleep(100); |
| 1301 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1302 | |
| 1303 | if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1304 | Adapter->DriverState = NO_NETWORK_ENTRY; |
| 1305 | wake_up(&Adapter->LEDInfo.notify_led_event); |
| 1306 | } |
| 1307 | |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1308 | Adapter->bTriedToWakeUpFromlowPowerMode = false; |
| 1309 | Adapter->bShutStatus = false; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1310 | wake_up(&Adapter->lowpower_mode_wait_queue); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1311 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1312 | } |
| 1313 | |
Kevin McKinney | 7a15b79 | 2012-10-18 22:40:08 -0400 | [diff] [blame] | 1314 | static void SendShutModeResponse(struct bcm_mini_adapter *Adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1315 | { |
Kevin McKinney | 2610c7a | 2012-05-26 12:05:08 -0400 | [diff] [blame] | 1316 | struct bcm_link_request stShutdownResponse; |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1317 | unsigned int NVMAccess = 0, lowPwrAbortMsg = 0; |
| 1318 | unsigned int Status = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1319 | |
Kevin McKinney | 2610c7a | 2012-05-26 12:05:08 -0400 | [diff] [blame] | 1320 | memset(&stShutdownResponse, 0, sizeof(struct bcm_link_request)); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1321 | stShutdownResponse.Leader.Status = LINK_UP_CONTROL_REQ; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1322 | stShutdownResponse.Leader.PLength = 8; /* 8 bytes; */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1323 | stShutdownResponse.szData[0] = LINK_UP_ACK; |
| 1324 | stShutdownResponse.szData[1] = LINK_SHUTDOWN_REQ_FROM_FIRMWARE; |
| 1325 | |
| 1326 | /********************************* |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1327 | * down_trylock - |
| 1328 | * if [ semaphore is available ] |
| 1329 | * acquire semaphone and return value 0 ; |
| 1330 | * else |
| 1331 | * return non-zero value ; |
| 1332 | * |
| 1333 | ***********************************/ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1334 | |
| 1335 | NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1336 | lowPwrAbortMsg = down_trylock(&Adapter->LowPowerModeSync); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1337 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1338 | if (NVMAccess || lowPwrAbortMsg || atomic_read(&Adapter->TotalPacketCount)) { |
| 1339 | if (!NVMAccess) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1340 | up(&Adapter->NVMRdmWrmLock); |
| 1341 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1342 | if (!lowPwrAbortMsg) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1343 | up(&Adapter->LowPowerModeSync); |
| 1344 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1345 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Device Access is going on NACK the Shut Down MODE\n"); |
| 1346 | stShutdownResponse.szData[2] = SHUTDOWN_NACK_FROM_DRIVER; /* NACK- device access is going on. */ |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1347 | Adapter->bPreparingForLowPowerMode = false; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1348 | } else { |
| 1349 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Sending SHUTDOWN MODE ACK\n"); |
| 1350 | stShutdownResponse.szData[2] = SHUTDOWN_ACK_FROM_DRIVER; /* ShutDown ACK */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1351 | |
| 1352 | /* Wait for the LED to TURN OFF before sending ACK response */ |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1353 | if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { |
Kevin McKinney | 7af14134 | 2012-10-18 22:40:13 -0400 | [diff] [blame] | 1354 | int iRetVal = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1355 | |
| 1356 | /* Wake the LED Thread with LOWPOWER_MODE_ENTER State */ |
| 1357 | Adapter->DriverState = LOWPOWER_MODE_ENTER; |
| 1358 | wake_up(&Adapter->LEDInfo.notify_led_event); |
| 1359 | |
| 1360 | /* Wait for 1 SEC for LED to OFF */ |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1361 | iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent, Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000)); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1362 | |
| 1363 | /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */ |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1364 | if (iRetVal <= 0) { |
| 1365 | stShutdownResponse.szData[1] = SHUTDOWN_NACK_FROM_DRIVER; /* NACK- device access is going on. */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1366 | Adapter->DriverState = NO_NETWORK_ENTRY; |
| 1367 | wake_up(&Adapter->LEDInfo.notify_led_event); |
| 1368 | } |
| 1369 | } |
| 1370 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1371 | if (stShutdownResponse.szData[2] == SHUTDOWN_ACK_FROM_DRIVER) { |
| 1372 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "ACKING SHUTDOWN MODE !!!!!!!!!"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1373 | down(&Adapter->rdmwrmsync); |
| 1374 | Adapter->bPreparingForLowPowerMode = TRUE; |
| 1375 | up(&Adapter->rdmwrmsync); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1376 | /* Killing all URBS. */ |
| 1377 | if (Adapter->bDoSuspend == TRUE) |
Kevin McKinney | d6861cf | 2012-11-01 23:42:21 -0400 | [diff] [blame] | 1378 | Bcm_kill_all_URBs((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter)); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1379 | } else { |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1380 | Adapter->bPreparingForLowPowerMode = false; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1381 | } |
| 1382 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1383 | if (!NVMAccess) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1384 | up(&Adapter->NVMRdmWrmLock); |
| 1385 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1386 | if (!lowPwrAbortMsg) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1387 | up(&Adapter->LowPowerModeSync); |
| 1388 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1389 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1390 | Status = CopyBufferToControlPacket(Adapter, &stShutdownResponse); |
Robin Schroer | 28c520a | 2014-06-16 13:01:47 +0200 | [diff] [blame] | 1391 | if (Status != STATUS_SUCCESS) { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1392 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "fail to send the Idle mode Request\n"); |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1393 | Adapter->bPreparingForLowPowerMode = false; |
Kevin McKinney | d6861cf | 2012-11-01 23:42:21 -0400 | [diff] [blame] | 1394 | StartInterruptUrb((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter)); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1395 | } |
| 1396 | } |
| 1397 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1398 | static void HandleShutDownModeRequest(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1399 | { |
Kevin McKinney | 7052208 | 2012-10-18 22:40:11 -0400 | [diff] [blame] | 1400 | unsigned int uiResetValue = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1401 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1402 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1403 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1404 | if (*(pucBuffer+1) == COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1405 | HandleShutDownModeWakeup(Adapter); |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1406 | } else if (*(pucBuffer+1) == LINK_SHUTDOWN_REQ_FROM_FIRMWARE) { |
| 1407 | /* Target wants to go to Shut Down Mode */ |
| 1408 | /* InterfacePrepareForShutdown(Adapter); */ |
| 1409 | if (Adapter->chip_id == BCS220_2 || |
| 1410 | Adapter->chip_id == BCS220_2BC || |
| 1411 | Adapter->chip_id == BCS250_BC || |
| 1412 | Adapter->chip_id == BCS220_3) { |
| 1413 | |
| 1414 | rdmalt(Adapter, HPM_CONFIG_MSW, &uiResetValue, 4); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1415 | uiResetValue |= (1<<17); |
| 1416 | wrmalt(Adapter, HPM_CONFIG_MSW, &uiResetValue, 4); |
| 1417 | } |
| 1418 | |
| 1419 | SendShutModeResponse(Adapter); |
Kevin McKinney | 7af14134 | 2012-10-18 22:40:13 -0400 | [diff] [blame] | 1420 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "ShutDownModeResponse:Notification received: Sending the response(Ack/Nack)\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1421 | } |
| 1422 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1423 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1424 | } |
| 1425 | |
Kevin McKinney | 7a15b79 | 2012-10-18 22:40:08 -0400 | [diff] [blame] | 1426 | void ResetCounters(struct bcm_mini_adapter *Adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1427 | { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1428 | beceem_protocol_reset(Adapter); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1429 | Adapter->CurrNumRecvDescs = 0; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1430 | Adapter->PrevNumRecvDescs = 0; |
| 1431 | Adapter->LinkUpStatus = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1432 | Adapter->LinkStatus = 0; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1433 | atomic_set(&Adapter->cntrlpktCnt, 0); |
| 1434 | atomic_set(&Adapter->TotalPacketCount, 0); |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1435 | Adapter->fw_download_done = false; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1436 | Adapter->LinkStatus = 0; |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1437 | Adapter->AutoLinkUp = false; |
| 1438 | Adapter->IdleMode = false; |
| 1439 | Adapter->bShutStatus = false; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1440 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1441 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1442 | struct bcm_classifier_rule *GetFragIPClsEntry(struct bcm_mini_adapter *Adapter, USHORT usIpIdentification, ULONG SrcIP) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1443 | { |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1444 | unsigned int uiIndex = 0; |
Robin Schroer | fe83073 | 2014-06-16 13:01:46 +0200 | [diff] [blame] | 1445 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1446 | for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) { |
| 1447 | if ((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) && |
| 1448 | (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification) && |
| 1449 | (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress == SrcIP) && |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1450 | !Adapter->astFragmentedPktClassifierTable[uiIndex].bOutOfOrderFragment) |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1451 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1452 | return Adapter->astFragmentedPktClassifierTable[uiIndex].pstMatchedClassifierEntry; |
| 1453 | } |
| 1454 | return NULL; |
| 1455 | } |
| 1456 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1457 | void AddFragIPClsEntry(struct bcm_mini_adapter *Adapter, struct bcm_fragmented_packet_info *psFragPktInfo) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1458 | { |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1459 | unsigned int uiIndex = 0; |
Robin Schroer | fe83073 | 2014-06-16 13:01:46 +0200 | [diff] [blame] | 1460 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1461 | for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) { |
| 1462 | if (!Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) { |
Kevin McKinney | 7f22485 | 2012-05-26 12:05:02 -0400 | [diff] [blame] | 1463 | memcpy(&Adapter->astFragmentedPktClassifierTable[uiIndex], psFragPktInfo, sizeof(struct bcm_fragmented_packet_info)); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1464 | break; |
| 1465 | } |
| 1466 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1467 | } |
| 1468 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1469 | void DelFragIPClsEntry(struct bcm_mini_adapter *Adapter, USHORT usIpIdentification, ULONG SrcIp) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1470 | { |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1471 | unsigned int uiIndex = 0; |
Robin Schroer | fe83073 | 2014-06-16 13:01:46 +0200 | [diff] [blame] | 1472 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1473 | for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) { |
| 1474 | if ((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) && |
| 1475 | (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification) && |
| 1476 | (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress == SrcIp)) |
| 1477 | |
Kevin McKinney | 7f22485 | 2012-05-26 12:05:02 -0400 | [diff] [blame] | 1478 | memset(&Adapter->astFragmentedPktClassifierTable[uiIndex], 0, sizeof(struct bcm_fragmented_packet_info)); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1479 | } |
| 1480 | } |
| 1481 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1482 | void update_per_cid_rx(struct bcm_mini_adapter *Adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1483 | { |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1484 | unsigned int qindex = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1485 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1486 | if ((jiffies - Adapter->liDrainCalculated) < XSECONDS) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1487 | return; |
| 1488 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1489 | for (qindex = 0; qindex < HiPriority; qindex++) { |
| 1490 | if (Adapter->PackInfo[qindex].ucDirection == 0) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1491 | Adapter->PackInfo[qindex].uiCurrentRxRate = |
| 1492 | (Adapter->PackInfo[qindex].uiCurrentRxRate + |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1493 | Adapter->PackInfo[qindex].uiThisPeriodRxBytes) / 2; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1494 | |
| 1495 | Adapter->PackInfo[qindex].uiThisPeriodRxBytes = 0; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1496 | } else { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1497 | Adapter->PackInfo[qindex].uiCurrentDrainRate = |
| 1498 | (Adapter->PackInfo[qindex].uiCurrentDrainRate + |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1499 | Adapter->PackInfo[qindex].uiThisPeriodSentBytes) / 2; |
| 1500 | Adapter->PackInfo[qindex].uiThisPeriodSentBytes = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1501 | } |
| 1502 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1503 | Adapter->liDrainCalculated = jiffies; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1504 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1505 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1506 | void update_per_sf_desc_cnts(struct bcm_mini_adapter *Adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1507 | { |
Kevin McKinney | 7af14134 | 2012-10-18 22:40:13 -0400 | [diff] [blame] | 1508 | int iIndex = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1509 | u32 uibuff[MAX_TARGET_DSX_BUFFERS]; |
Kevin McKinney | 41c7b7c | 2011-11-06 09:40:11 -0500 | [diff] [blame] | 1510 | int bytes; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1511 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1512 | if (!atomic_read(&Adapter->uiMBupdate)) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1513 | return; |
| 1514 | |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1515 | bytes = rdmaltWithLock(Adapter, TARGET_SFID_TXDESC_MAP_LOC, (unsigned int *)uibuff, sizeof(unsigned int) * MAX_TARGET_DSX_BUFFERS); |
Kevin McKinney | 41c7b7c | 2011-11-06 09:40:11 -0500 | [diff] [blame] | 1516 | if (bytes < 0) { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1517 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "rdm failed\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1518 | return; |
| 1519 | } |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1520 | |
| 1521 | for (iIndex = 0; iIndex < HiPriority; iIndex++) { |
| 1522 | if (Adapter->PackInfo[iIndex].bValid && Adapter->PackInfo[iIndex].ucDirection) { |
| 1523 | if (Adapter->PackInfo[iIndex].usVCID_Value < MAX_TARGET_DSX_BUFFERS) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1524 | atomic_set(&Adapter->PackInfo[iIndex].uiPerSFTxResourceCount, uibuff[Adapter->PackInfo[iIndex].usVCID_Value]); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1525 | else |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1526 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid VCID : %x\n", Adapter->PackInfo[iIndex].usVCID_Value); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1527 | } |
| 1528 | } |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1529 | atomic_set(&Adapter->uiMBupdate, false); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1530 | } |
| 1531 | |
Kevin McKinney | 9ef0760 | 2012-10-18 22:40:12 -0400 | [diff] [blame] | 1532 | void flush_queue(struct bcm_mini_adapter *Adapter, unsigned int iQIndex) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1533 | { |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1534 | struct sk_buff *PacketToDrop = NULL; |
| 1535 | struct net_device_stats *netstats = &Adapter->dev->stats; |
Robin Schroer | fe83073 | 2014-06-16 13:01:46 +0200 | [diff] [blame] | 1536 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1537 | spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); |
| 1538 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1539 | while (Adapter->PackInfo[iQIndex].FirstTxQueue && atomic_read(&Adapter->TotalPacketCount)) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1540 | PacketToDrop = Adapter->PackInfo[iQIndex].FirstTxQueue; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1541 | if (PacketToDrop && PacketToDrop->len) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1542 | netstats->tx_dropped++; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1543 | DEQUEUEPACKET(Adapter->PackInfo[iQIndex].FirstTxQueue, Adapter->PackInfo[iQIndex].LastTxQueue); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1544 | Adapter->PackInfo[iQIndex].uiCurrentPacketsOnHost--; |
| 1545 | Adapter->PackInfo[iQIndex].uiCurrentBytesOnHost -= PacketToDrop->len; |
| 1546 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1547 | /* Adding dropped statistics */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1548 | Adapter->PackInfo[iQIndex].uiDroppedCountBytes += PacketToDrop->len; |
| 1549 | Adapter->PackInfo[iQIndex].uiDroppedCountPackets++; |
Stephen Hemminger | 082e889 | 2010-11-01 09:35:21 -0400 | [diff] [blame] | 1550 | dev_kfree_skb(PacketToDrop); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1551 | atomic_dec(&Adapter->TotalPacketCount); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1552 | } |
| 1553 | } |
| 1554 | spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1555 | } |
| 1556 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1557 | static void beceem_protocol_reset(struct bcm_mini_adapter *Adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1558 | { |
Stephen Hemminger | 4fd64dd | 2010-11-01 12:12:31 -0400 | [diff] [blame] | 1559 | int i; |
Robin Schroer | fe83073 | 2014-06-16 13:01:46 +0200 | [diff] [blame] | 1560 | |
Stephen Hemminger | 4fd64dd | 2010-11-01 12:12:31 -0400 | [diff] [blame] | 1561 | if (netif_msg_link(Adapter)) |
Stephen Hemminger | 9ec4475 | 2010-11-01 12:18:36 -0400 | [diff] [blame] | 1562 | pr_notice(PFX "%s: protocol reset\n", Adapter->dev->name); |
Stephen Hemminger | 4fd64dd | 2010-11-01 12:12:31 -0400 | [diff] [blame] | 1563 | |
| 1564 | netif_carrier_off(Adapter->dev); |
| 1565 | netif_stop_queue(Adapter->dev); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1566 | |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1567 | Adapter->IdleMode = false; |
| 1568 | Adapter->LinkUpStatus = false; |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1569 | ClearTargetDSXBuffer(Adapter, 0, TRUE); |
| 1570 | /* Delete All Classifier Rules */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1571 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1572 | for (i = 0; i < HiPriority; i++) |
| 1573 | DeleteAllClassifiersForSF(Adapter, i); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1574 | |
| 1575 | flush_all_queues(Adapter); |
| 1576 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1577 | if (Adapter->TimerActive == TRUE) |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1578 | Adapter->TimerActive = false; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1579 | |
Kevin McKinney | 7f22485 | 2012-05-26 12:05:02 -0400 | [diff] [blame] | 1580 | memset(Adapter->astFragmentedPktClassifierTable, 0, sizeof(struct bcm_fragmented_packet_info) * MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1581 | |
Kevin McKinney | 6a4ef5f | 2011-10-07 18:50:09 -0400 | [diff] [blame] | 1582 | for (i = 0; i < HiPriority; i++) { |
| 1583 | /* resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF. */ |
| 1584 | /* It is same between MIBs and SF. */ |
Kevin McKinney | 8c7d51a | 2012-11-25 19:28:59 -0500 | [diff] [blame] | 1585 | memset(&Adapter->PackInfo[i].stMibsExtServiceFlowTable, 0, sizeof(struct bcm_mibs_parameters)); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1586 | } |
| 1587 | } |