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