2198 abort_with_nothing:
2199 return (DDI_FAILURE);
2200 }
2201
2202 static void
2203 myri10ge_stop_locked(struct myri10ge_priv *mgp)
2204 {
2205 int status, old_down_cnt;
2206 myri10ge_cmd_t cmd;
2207 int wait_time = 10;
2208 int i, polling;
2209
2210 old_down_cnt = mgp->down_cnt;
2211 mb();
2212 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_DOWN, &cmd);
2213 if (status) {
2214 cmn_err(CE_WARN, "%s: Couldn't bring down link\n", mgp->name);
2215 }
2216
2217 while (old_down_cnt == *((volatile int *)&mgp->down_cnt)) {
2218 delay(1 * drv_usectohz(1000000));
2219 wait_time--;
2220 if (wait_time == 0)
2221 break;
2222 }
2223 again:
2224 if (old_down_cnt == *((volatile int *)&mgp->down_cnt)) {
2225 cmn_err(CE_WARN, "%s: didn't get down irq\n", mgp->name);
2226 for (i = 0; i < mgp->num_slices; i++) {
2227 /*
2228 * take and release the rx lock to ensure
2229 * that no interrupt thread is blocked
2230 * elsewhere in the stack, preventing
2231 * completion
2232 */
2233
2234 mutex_enter(&mgp->ss[i].rx_lock);
2235 printf("%s: slice %d rx irq idle\n",
2236 mgp->name, i);
2237 mutex_exit(&mgp->ss[i].rx_lock);
2238
2239 /* verify that the poll handler is inactive */
2240 mutex_enter(&mgp->ss->poll_lock);
2241 polling = mgp->ss->rx_polling;
2242 mutex_exit(&mgp->ss->poll_lock);
2243 if (polling) {
2244 printf("%s: slice %d is polling\n",
2245 mgp->name, i);
2246 delay(1 * drv_usectohz(1000000));
2247 goto again;
2248 }
2249 }
2250 delay(1 * drv_usectohz(1000000));
2251 if (old_down_cnt == *((volatile int *)&mgp->down_cnt)) {
2252 cmn_err(CE_WARN, "%s: Never got down irq\n", mgp->name);
2253 }
2254 }
2255
2256 for (i = 0; i < mgp->num_slices; i++)
2257 myri10ge_teardown_slice(&mgp->ss[i]);
2258
2259 if (mgp->toeplitz_hash_table != NULL) {
2260 kmem_free(mgp->toeplitz_hash_table,
2261 sizeof (uint32_t) * 12 * 256);
2262 mgp->toeplitz_hash_table = NULL;
2263 }
2264 mgp->running = MYRI10GE_ETH_STOPPED;
2265 }
2266
2267 static int
2268 myri10ge_m_start(void *arg)
2269 {
2270 struct myri10ge_priv *mgp = arg;
5860 goto abort_with_macinfo;
5861 }
5862 ddi_set_driver_private(dip, mgp);
5863
5864 /* setup device name for log messages */
5865 (void) sprintf(mgp->name, "myri10ge%d", ddi_get_instance(dip));
5866
5867 mutex_enter(&myri10ge_param_lock);
5868 myri10ge_get_props(dip);
5869 mgp->intr_coal_delay = myri10ge_intr_coal_delay;
5870 mgp->pause = myri10ge_flow_control;
5871 mutex_exit(&myri10ge_param_lock);
5872
5873 mgp->max_read_request_4k = max_read_request_4k;
5874 mgp->pcie_link_width = link_width;
5875 mgp->running = MYRI10GE_ETH_STOPPED;
5876 mgp->vso = vso;
5877 mgp->dip = dip;
5878 mgp->cfg_hdl = handle;
5879
5880 mgp->timer_ticks = 5 * drv_usectohz(1000000); /* 5 seconds */
5881 myri10ge_test_physical(dip);
5882
5883 /* allocate command page */
5884 bytes = sizeof (*mgp->cmd);
5885 mgp->cmd = (mcp_cmd_response_t *)
5886 (void *)myri10ge_dma_alloc(dip, bytes,
5887 &myri10ge_misc_dma_attr, &myri10ge_dev_access_attr,
5888 DDI_DMA_CONSISTENT, DDI_DMA_RDWR|DDI_DMA_CONSISTENT,
5889 &mgp->cmd_dma, 1, DDI_DMA_DONTWAIT);
5890 if (mgp->cmd == NULL)
5891 goto abort_with_mgp;
5892
5893 (void) myri10ge_reg_set(dip, &mgp->reg_set, &span, &bus_number,
5894 &dev_number, &func_number);
5895 if (myri10ge_verbose)
5896 printf("%s at %ld:%ld:%ld attaching\n", mgp->name,
5897 bus_number, dev_number, func_number);
5898 status = ddi_regs_map_setup(dip, mgp->reg_set, (caddr_t *)&mgp->sram,
5899 (offset_t)0, (offset_t)span, &myri10ge_dev_access_attr,
5900 &mgp->io_handle);
|
2198 abort_with_nothing:
2199 return (DDI_FAILURE);
2200 }
2201
2202 static void
2203 myri10ge_stop_locked(struct myri10ge_priv *mgp)
2204 {
2205 int status, old_down_cnt;
2206 myri10ge_cmd_t cmd;
2207 int wait_time = 10;
2208 int i, polling;
2209
2210 old_down_cnt = mgp->down_cnt;
2211 mb();
2212 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_DOWN, &cmd);
2213 if (status) {
2214 cmn_err(CE_WARN, "%s: Couldn't bring down link\n", mgp->name);
2215 }
2216
2217 while (old_down_cnt == *((volatile int *)&mgp->down_cnt)) {
2218 delay(drv_sectohz(1));
2219 wait_time--;
2220 if (wait_time == 0)
2221 break;
2222 }
2223 again:
2224 if (old_down_cnt == *((volatile int *)&mgp->down_cnt)) {
2225 cmn_err(CE_WARN, "%s: didn't get down irq\n", mgp->name);
2226 for (i = 0; i < mgp->num_slices; i++) {
2227 /*
2228 * take and release the rx lock to ensure
2229 * that no interrupt thread is blocked
2230 * elsewhere in the stack, preventing
2231 * completion
2232 */
2233
2234 mutex_enter(&mgp->ss[i].rx_lock);
2235 printf("%s: slice %d rx irq idle\n",
2236 mgp->name, i);
2237 mutex_exit(&mgp->ss[i].rx_lock);
2238
2239 /* verify that the poll handler is inactive */
2240 mutex_enter(&mgp->ss->poll_lock);
2241 polling = mgp->ss->rx_polling;
2242 mutex_exit(&mgp->ss->poll_lock);
2243 if (polling) {
2244 printf("%s: slice %d is polling\n",
2245 mgp->name, i);
2246 delay(drv_sectohz(1));
2247 goto again;
2248 }
2249 }
2250 delay(drv_sectohz(1));
2251 if (old_down_cnt == *((volatile int *)&mgp->down_cnt)) {
2252 cmn_err(CE_WARN, "%s: Never got down irq\n", mgp->name);
2253 }
2254 }
2255
2256 for (i = 0; i < mgp->num_slices; i++)
2257 myri10ge_teardown_slice(&mgp->ss[i]);
2258
2259 if (mgp->toeplitz_hash_table != NULL) {
2260 kmem_free(mgp->toeplitz_hash_table,
2261 sizeof (uint32_t) * 12 * 256);
2262 mgp->toeplitz_hash_table = NULL;
2263 }
2264 mgp->running = MYRI10GE_ETH_STOPPED;
2265 }
2266
2267 static int
2268 myri10ge_m_start(void *arg)
2269 {
2270 struct myri10ge_priv *mgp = arg;
5860 goto abort_with_macinfo;
5861 }
5862 ddi_set_driver_private(dip, mgp);
5863
5864 /* setup device name for log messages */
5865 (void) sprintf(mgp->name, "myri10ge%d", ddi_get_instance(dip));
5866
5867 mutex_enter(&myri10ge_param_lock);
5868 myri10ge_get_props(dip);
5869 mgp->intr_coal_delay = myri10ge_intr_coal_delay;
5870 mgp->pause = myri10ge_flow_control;
5871 mutex_exit(&myri10ge_param_lock);
5872
5873 mgp->max_read_request_4k = max_read_request_4k;
5874 mgp->pcie_link_width = link_width;
5875 mgp->running = MYRI10GE_ETH_STOPPED;
5876 mgp->vso = vso;
5877 mgp->dip = dip;
5878 mgp->cfg_hdl = handle;
5879
5880 mgp->timer_ticks = drv_sectohz(5);
5881 myri10ge_test_physical(dip);
5882
5883 /* allocate command page */
5884 bytes = sizeof (*mgp->cmd);
5885 mgp->cmd = (mcp_cmd_response_t *)
5886 (void *)myri10ge_dma_alloc(dip, bytes,
5887 &myri10ge_misc_dma_attr, &myri10ge_dev_access_attr,
5888 DDI_DMA_CONSISTENT, DDI_DMA_RDWR|DDI_DMA_CONSISTENT,
5889 &mgp->cmd_dma, 1, DDI_DMA_DONTWAIT);
5890 if (mgp->cmd == NULL)
5891 goto abort_with_mgp;
5892
5893 (void) myri10ge_reg_set(dip, &mgp->reg_set, &span, &bus_number,
5894 &dev_number, &func_number);
5895 if (myri10ge_verbose)
5896 printf("%s at %ld:%ld:%ld attaching\n", mgp->name,
5897 bus_number, dev_number, func_number);
5898 status = ddi_regs_map_setup(dip, mgp->reg_set, (caddr_t *)&mgp->sram,
5899 (offset_t)0, (offset_t)span, &myri10ge_dev_access_attr,
5900 &mgp->io_handle);
|