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