Lines Matching refs:qdev
4 int ql_unpause_mpi_risc(struct ql_adapter *qdev) in ql_unpause_mpi_risc() argument
9 tmp = ql_read32(qdev, CSR); in ql_unpause_mpi_risc()
13 ql_write32(qdev, CSR, CSR_CMD_CLR_PAUSE); in ql_unpause_mpi_risc()
17 int ql_pause_mpi_risc(struct ql_adapter *qdev) in ql_pause_mpi_risc() argument
23 ql_write32(qdev, CSR, CSR_CMD_SET_PAUSE); in ql_pause_mpi_risc()
25 tmp = ql_read32(qdev, CSR); in ql_pause_mpi_risc()
34 int ql_hard_reset_mpi_risc(struct ql_adapter *qdev) in ql_hard_reset_mpi_risc() argument
40 ql_write32(qdev, CSR, CSR_CMD_SET_RST); in ql_hard_reset_mpi_risc()
42 tmp = ql_read32(qdev, CSR); in ql_hard_reset_mpi_risc()
44 ql_write32(qdev, CSR, CSR_CMD_CLR_RST); in ql_hard_reset_mpi_risc()
53 int ql_read_mpi_reg(struct ql_adapter *qdev, u32 reg, u32 *data) in ql_read_mpi_reg() argument
57 status = ql_wait_reg_rdy(qdev, PROC_ADDR, PROC_ADDR_RDY, PROC_ADDR_ERR); in ql_read_mpi_reg()
61 ql_write32(qdev, PROC_ADDR, reg | PROC_ADDR_R); in ql_read_mpi_reg()
63 status = ql_wait_reg_rdy(qdev, PROC_ADDR, PROC_ADDR_RDY, PROC_ADDR_ERR); in ql_read_mpi_reg()
67 *data = ql_read32(qdev, PROC_DATA); in ql_read_mpi_reg()
72 int ql_write_mpi_reg(struct ql_adapter *qdev, u32 reg, u32 data) in ql_write_mpi_reg() argument
76 status = ql_wait_reg_rdy(qdev, PROC_ADDR, PROC_ADDR_RDY, PROC_ADDR_ERR); in ql_write_mpi_reg()
80 ql_write32(qdev, PROC_DATA, data); in ql_write_mpi_reg()
82 ql_write32(qdev, PROC_ADDR, reg); in ql_write_mpi_reg()
84 status = ql_wait_reg_rdy(qdev, PROC_ADDR, PROC_ADDR_RDY, PROC_ADDR_ERR); in ql_write_mpi_reg()
91 int ql_soft_reset_mpi_risc(struct ql_adapter *qdev) in ql_soft_reset_mpi_risc() argument
94 status = ql_write_mpi_reg(qdev, 0x00001010, 1); in ql_soft_reset_mpi_risc()
103 int ql_own_firmware(struct ql_adapter *qdev) in ql_own_firmware() argument
111 if (qdev->func < qdev->alt_func) in ql_own_firmware()
119 temp = ql_read32(qdev, STS); in ql_own_firmware()
120 if (!(temp & (1 << (8 + qdev->alt_func)))) in ql_own_firmware()
127 static int ql_get_mb_sts(struct ql_adapter *qdev, struct mbox_params *mbcp) in ql_get_mb_sts() argument
131 status = ql_sem_spinlock(qdev, SEM_PROC_REG_MASK); in ql_get_mb_sts()
136 ql_read_mpi_reg(qdev, qdev->mailbox_out + i, in ql_get_mb_sts()
139 netif_err(qdev, drv, qdev->ndev, "Failed mailbox read.\n"); in ql_get_mb_sts()
143 ql_sem_unlock(qdev, SEM_PROC_REG_MASK); /* does flush too */ in ql_get_mb_sts()
150 static int ql_wait_mbx_cmd_cmplt(struct ql_adapter *qdev) in ql_wait_mbx_cmd_cmplt() argument
156 value = ql_read32(qdev, STS); in ql_wait_mbx_cmd_cmplt()
167 static int ql_exec_mb_cmd(struct ql_adapter *qdev, struct mbox_params *mbcp) in ql_exec_mb_cmd() argument
175 if (ql_read32(qdev, CSR) & CSR_HRI) in ql_exec_mb_cmd()
178 status = ql_sem_spinlock(qdev, SEM_PROC_REG_MASK); in ql_exec_mb_cmd()
186 status = ql_write_mpi_reg(qdev, qdev->mailbox_in + i, in ql_exec_mb_cmd()
194 ql_write32(qdev, CSR, CSR_CMD_SET_H2R_INT); in ql_exec_mb_cmd()
196 ql_sem_unlock(qdev, SEM_PROC_REG_MASK); in ql_exec_mb_cmd()
207 static int ql_idc_req_aen(struct ql_adapter *qdev) in ql_idc_req_aen() argument
210 struct mbox_params *mbcp = &qdev->idc_mbc; in ql_idc_req_aen()
212 netif_err(qdev, drv, qdev->ndev, "Enter!\n"); in ql_idc_req_aen()
216 mbcp = &qdev->idc_mbc; in ql_idc_req_aen()
218 status = ql_get_mb_sts(qdev, mbcp); in ql_idc_req_aen()
220 netif_err(qdev, drv, qdev->ndev, in ql_idc_req_aen()
222 ql_queue_asic_error(qdev); in ql_idc_req_aen()
228 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16)); in ql_idc_req_aen()
229 queue_delayed_work(qdev->workqueue, &qdev->mpi_idc_work, 0); in ql_idc_req_aen()
237 static int ql_idc_cmplt_aen(struct ql_adapter *qdev) in ql_idc_cmplt_aen() argument
240 struct mbox_params *mbcp = &qdev->idc_mbc; in ql_idc_cmplt_aen()
242 status = ql_get_mb_sts(qdev, mbcp); in ql_idc_cmplt_aen()
244 netif_err(qdev, drv, qdev->ndev, in ql_idc_cmplt_aen()
246 ql_queue_fw_error(qdev); in ql_idc_cmplt_aen()
251 complete(&qdev->ide_completion); in ql_idc_cmplt_aen()
256 static void ql_link_up(struct ql_adapter *qdev, struct mbox_params *mbcp) in ql_link_up() argument
261 status = ql_get_mb_sts(qdev, mbcp); in ql_link_up()
263 netif_err(qdev, drv, qdev->ndev, in ql_link_up()
268 qdev->link_status = mbcp->mbox_out[1]; in ql_link_up()
269 netif_err(qdev, drv, qdev->ndev, "Link Up.\n"); in ql_link_up()
274 if (test_bit(QL_CAM_RT_SET, &qdev->flags)) { in ql_link_up()
275 status = ql_cam_route_initialize(qdev); in ql_link_up()
277 netif_err(qdev, ifup, qdev->ndev, in ql_link_up()
281 clear_bit(QL_CAM_RT_SET, &qdev->flags); in ql_link_up()
288 if (!test_bit(QL_PORT_CFG, &qdev->flags)) { in ql_link_up()
289 netif_err(qdev, drv, qdev->ndev, "Queue Port Config Worker!\n"); in ql_link_up()
290 set_bit(QL_PORT_CFG, &qdev->flags); in ql_link_up()
295 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16)); in ql_link_up()
296 queue_delayed_work(qdev->workqueue, in ql_link_up()
297 &qdev->mpi_port_cfg_work, 0); in ql_link_up()
300 ql_link_on(qdev); in ql_link_up()
303 static void ql_link_down(struct ql_adapter *qdev, struct mbox_params *mbcp) in ql_link_down() argument
309 status = ql_get_mb_sts(qdev, mbcp); in ql_link_down()
311 netif_err(qdev, drv, qdev->ndev, "Link down AEN broken!\n"); in ql_link_down()
313 ql_link_off(qdev); in ql_link_down()
316 static int ql_sfp_in(struct ql_adapter *qdev, struct mbox_params *mbcp) in ql_sfp_in() argument
322 status = ql_get_mb_sts(qdev, mbcp); in ql_sfp_in()
324 netif_err(qdev, drv, qdev->ndev, "SFP in AEN broken!\n"); in ql_sfp_in()
326 netif_err(qdev, drv, qdev->ndev, "SFP insertion detected.\n"); in ql_sfp_in()
331 static int ql_sfp_out(struct ql_adapter *qdev, struct mbox_params *mbcp) in ql_sfp_out() argument
337 status = ql_get_mb_sts(qdev, mbcp); in ql_sfp_out()
339 netif_err(qdev, drv, qdev->ndev, "SFP out AEN broken!\n"); in ql_sfp_out()
341 netif_err(qdev, drv, qdev->ndev, "SFP removal detected.\n"); in ql_sfp_out()
346 static int ql_aen_lost(struct ql_adapter *qdev, struct mbox_params *mbcp) in ql_aen_lost() argument
352 status = ql_get_mb_sts(qdev, mbcp); in ql_aen_lost()
354 netif_err(qdev, drv, qdev->ndev, "Lost AEN broken!\n"); in ql_aen_lost()
357 netif_err(qdev, drv, qdev->ndev, "Lost AEN detected.\n"); in ql_aen_lost()
359 netif_err(qdev, drv, qdev->ndev, "mbox_out[%d] = 0x%.08x.\n", in ql_aen_lost()
367 static void ql_init_fw_done(struct ql_adapter *qdev, struct mbox_params *mbcp) in ql_init_fw_done() argument
373 status = ql_get_mb_sts(qdev, mbcp); in ql_init_fw_done()
375 netif_err(qdev, drv, qdev->ndev, "Firmware did not initialize!\n"); in ql_init_fw_done()
377 netif_err(qdev, drv, qdev->ndev, "Firmware Revision = 0x%.08x.\n", in ql_init_fw_done()
379 qdev->fw_rev_id = mbcp->mbox_out[1]; in ql_init_fw_done()
380 status = ql_cam_route_initialize(qdev); in ql_init_fw_done()
382 netif_err(qdev, ifup, qdev->ndev, in ql_init_fw_done()
393 static int ql_mpi_handler(struct ql_adapter *qdev, struct mbox_params *mbcp) in ql_mpi_handler() argument
400 status = ql_get_mb_sts(qdev, mbcp); in ql_mpi_handler()
402 netif_err(qdev, drv, qdev->ndev, in ql_mpi_handler()
404 ql_queue_asic_error(qdev); in ql_mpi_handler()
428 status = ql_get_mb_sts(qdev, mbcp); in ql_mpi_handler()
437 status = ql_idc_req_aen(qdev); in ql_mpi_handler()
447 status = ql_idc_cmplt_aen(qdev); in ql_mpi_handler()
451 ql_link_up(qdev, mbcp); in ql_mpi_handler()
455 ql_link_down(qdev, mbcp); in ql_mpi_handler()
464 status = ql_get_mb_sts(qdev, mbcp); in ql_mpi_handler()
468 ql_init_fw_done(qdev, mbcp); in ql_mpi_handler()
472 ql_sfp_in(qdev, mbcp); in ql_mpi_handler()
476 ql_sfp_out(qdev, mbcp); in ql_mpi_handler()
488 status = ql_get_mb_sts(qdev, mbcp); in ql_mpi_handler()
492 netif_err(qdev, drv, qdev->ndev, in ql_mpi_handler()
495 ql_queue_fw_error(qdev); in ql_mpi_handler()
499 netif_err(qdev, drv, qdev->ndev, "System Error.\n"); in ql_mpi_handler()
500 ql_queue_fw_error(qdev); in ql_mpi_handler()
505 ql_aen_lost(qdev, mbcp); in ql_mpi_handler()
512 netif_err(qdev, drv, qdev->ndev, in ql_mpi_handler()
517 ql_write32(qdev, CSR, CSR_CMD_CLR_R2PCI_INT); in ql_mpi_handler()
533 static int ql_mailbox_command(struct ql_adapter *qdev, struct mbox_params *mbcp) in ql_mailbox_command() argument
538 mutex_lock(&qdev->mpi_mutex); in ql_mailbox_command()
541 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16)); in ql_mailbox_command()
544 status = ql_exec_mb_cmd(qdev, mbcp); in ql_mailbox_command()
563 status = ql_wait_mbx_cmd_cmplt(qdev); in ql_mailbox_command()
572 status = ql_mpi_handler(qdev, mbcp); in ql_mailbox_command()
587 netif_err(qdev, drv, qdev->ndev, in ql_mailbox_command()
597 ql_write32(qdev, CSR, CSR_CMD_CLR_R2PCI_INT); in ql_mailbox_command()
607 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16) | INTR_MASK_PI); in ql_mailbox_command()
608 mutex_unlock(&qdev->mpi_mutex); in ql_mailbox_command()
616 int ql_mb_about_fw(struct ql_adapter *qdev) in ql_mb_about_fw() argument
629 status = ql_mailbox_command(qdev, mbcp); in ql_mb_about_fw()
634 netif_err(qdev, drv, qdev->ndev, in ql_mb_about_fw()
640 qdev->fw_rev_id = mbcp->mbox_out[1]; in ql_mb_about_fw()
648 int ql_mb_get_fw_state(struct ql_adapter *qdev) in ql_mb_get_fw_state() argument
661 status = ql_mailbox_command(qdev, mbcp); in ql_mb_get_fw_state()
666 netif_err(qdev, drv, qdev->ndev, in ql_mb_get_fw_state()
676 netif_err(qdev, drv, qdev->ndev, in ql_mb_get_fw_state()
687 static int ql_mb_idc_ack(struct ql_adapter *qdev) in ql_mb_idc_ack() argument
699 mbcp->mbox_in[1] = qdev->idc_mbc.mbox_out[1]; in ql_mb_idc_ack()
700 mbcp->mbox_in[2] = qdev->idc_mbc.mbox_out[2]; in ql_mb_idc_ack()
701 mbcp->mbox_in[3] = qdev->idc_mbc.mbox_out[3]; in ql_mb_idc_ack()
702 mbcp->mbox_in[4] = qdev->idc_mbc.mbox_out[4]; in ql_mb_idc_ack()
704 status = ql_mailbox_command(qdev, mbcp); in ql_mb_idc_ack()
709 netif_err(qdev, drv, qdev->ndev, "Failed IDC ACK send.\n"); in ql_mb_idc_ack()
719 int ql_mb_set_port_cfg(struct ql_adapter *qdev) in ql_mb_set_port_cfg() argument
731 mbcp->mbox_in[1] = qdev->link_config; in ql_mb_set_port_cfg()
732 mbcp->mbox_in[2] = qdev->max_frame_size; in ql_mb_set_port_cfg()
735 status = ql_mailbox_command(qdev, mbcp); in ql_mb_set_port_cfg()
740 netif_err(qdev, drv, qdev->ndev, in ql_mb_set_port_cfg()
743 netif_err(qdev, drv, qdev->ndev, in ql_mb_set_port_cfg()
750 static int ql_mb_dump_ram(struct ql_adapter *qdev, u64 req_dma, u32 addr, in ql_mb_dump_ram() argument
773 status = ql_mailbox_command(qdev, mbcp); in ql_mb_dump_ram()
778 netif_err(qdev, drv, qdev->ndev, "Failed to dump risc RAM.\n"); in ql_mb_dump_ram()
785 int ql_dump_risc_ram_area(struct ql_adapter *qdev, void *buf, in ql_dump_risc_ram_area() argument
792 my_buf = pci_alloc_consistent(qdev->pdev, word_count * sizeof(u32), in ql_dump_risc_ram_area()
797 status = ql_mb_dump_ram(qdev, buf_dma, ram_addr, word_count); in ql_dump_risc_ram_area()
801 pci_free_consistent(qdev->pdev, word_count * sizeof(u32), my_buf, in ql_dump_risc_ram_area()
810 int ql_mb_get_port_cfg(struct ql_adapter *qdev) in ql_mb_get_port_cfg() argument
823 status = ql_mailbox_command(qdev, mbcp); in ql_mb_get_port_cfg()
828 netif_err(qdev, drv, qdev->ndev, in ql_mb_get_port_cfg()
832 netif_printk(qdev, drv, KERN_DEBUG, qdev->ndev, in ql_mb_get_port_cfg()
834 qdev->link_config = mbcp->mbox_out[1]; in ql_mb_get_port_cfg()
835 qdev->max_frame_size = mbcp->mbox_out[2]; in ql_mb_get_port_cfg()
840 int ql_mb_wol_mode(struct ql_adapter *qdev, u32 wol) in ql_mb_wol_mode() argument
855 status = ql_mailbox_command(qdev, mbcp); in ql_mb_wol_mode()
860 netif_err(qdev, drv, qdev->ndev, "Failed to set WOL mode.\n"); in ql_mb_wol_mode()
866 int ql_mb_wol_set_magic(struct ql_adapter *qdev, u32 enable_wol) in ql_mb_wol_set_magic() argument
871 u8 *addr = qdev->ndev->dev_addr; in ql_mb_wol_set_magic()
897 status = ql_mailbox_command(qdev, mbcp); in ql_mb_wol_set_magic()
902 netif_err(qdev, drv, qdev->ndev, "Failed to set WOL mode.\n"); in ql_mb_wol_set_magic()
915 static int ql_idc_wait(struct ql_adapter *qdev) in ql_idc_wait() argument
919 struct mbox_params *mbcp = &qdev->idc_mbc; in ql_idc_wait()
925 wait_for_completion_timeout(&qdev->ide_completion, in ql_idc_wait()
928 netif_err(qdev, drv, qdev->ndev, "IDC Timeout.\n"); in ql_idc_wait()
936 netif_err(qdev, drv, qdev->ndev, in ql_idc_wait()
940 netif_err(qdev, drv, qdev->ndev, "IDC Success.\n"); in ql_idc_wait()
944 netif_err(qdev, drv, qdev->ndev, in ql_idc_wait()
955 int ql_mb_set_led_cfg(struct ql_adapter *qdev, u32 led_config) in ql_mb_set_led_cfg() argument
970 status = ql_mailbox_command(qdev, mbcp); in ql_mb_set_led_cfg()
975 netif_err(qdev, drv, qdev->ndev, in ql_mb_set_led_cfg()
983 int ql_mb_get_led_cfg(struct ql_adapter *qdev) in ql_mb_get_led_cfg() argument
996 status = ql_mailbox_command(qdev, mbcp); in ql_mb_get_led_cfg()
1001 netif_err(qdev, drv, qdev->ndev, in ql_mb_get_led_cfg()
1005 qdev->led_config = mbcp->mbox_out[1]; in ql_mb_get_led_cfg()
1010 int ql_mb_set_mgmnt_traffic_ctl(struct ql_adapter *qdev, u32 control) in ql_mb_set_mgmnt_traffic_ctl() argument
1024 status = ql_mailbox_command(qdev, mbcp); in ql_mb_set_mgmnt_traffic_ctl()
1032 netif_err(qdev, drv, qdev->ndev, in ql_mb_set_mgmnt_traffic_ctl()
1040 netif_err(qdev, drv, qdev->ndev, in ql_mb_set_mgmnt_traffic_ctl()
1047 static int ql_mb_get_mgmnt_traffic_ctl(struct ql_adapter *qdev, u32 *control) in ql_mb_get_mgmnt_traffic_ctl() argument
1061 status = ql_mailbox_command(qdev, mbcp); in ql_mb_get_mgmnt_traffic_ctl()
1071 netif_err(qdev, drv, qdev->ndev, in ql_mb_get_mgmnt_traffic_ctl()
1075 netif_err(qdev, drv, qdev->ndev, in ql_mb_get_mgmnt_traffic_ctl()
1082 int ql_wait_fifo_empty(struct ql_adapter *qdev) in ql_wait_fifo_empty() argument
1089 nic_fifo_empty = ql_read32(qdev, STS) & STS_NFE; in ql_wait_fifo_empty()
1090 ql_mb_get_mgmnt_traffic_ctl(qdev, &mgmnt_fifo_empty); in ql_wait_fifo_empty()
1102 static int ql_set_port_cfg(struct ql_adapter *qdev) in ql_set_port_cfg() argument
1105 status = ql_mb_set_port_cfg(qdev); in ql_set_port_cfg()
1108 status = ql_idc_wait(qdev); in ql_set_port_cfg()
1122 struct ql_adapter *qdev = in ql_mpi_port_cfg_work() local
1126 status = ql_mb_get_port_cfg(qdev); in ql_mpi_port_cfg_work()
1128 netif_err(qdev, drv, qdev->ndev, in ql_mpi_port_cfg_work()
1133 if (qdev->link_config & CFG_JUMBO_FRAME_SIZE && in ql_mpi_port_cfg_work()
1134 qdev->max_frame_size == in ql_mpi_port_cfg_work()
1138 qdev->link_config |= CFG_JUMBO_FRAME_SIZE; in ql_mpi_port_cfg_work()
1139 qdev->max_frame_size = CFG_DEFAULT_MAX_FRAME_SIZE; in ql_mpi_port_cfg_work()
1140 status = ql_set_port_cfg(qdev); in ql_mpi_port_cfg_work()
1142 netif_err(qdev, drv, qdev->ndev, in ql_mpi_port_cfg_work()
1147 clear_bit(QL_PORT_CFG, &qdev->flags); in ql_mpi_port_cfg_work()
1150 ql_queue_fw_error(qdev); in ql_mpi_port_cfg_work()
1162 struct ql_adapter *qdev = in ql_mpi_idc_work() local
1165 struct mbox_params *mbcp = &qdev->idc_mbc; in ql_mpi_idc_work()
1174 netif_err(qdev, drv, qdev->ndev, in ql_mpi_idc_work()
1179 ql_link_off(qdev); in ql_mpi_idc_work()
1185 set_bit(QL_CAM_RT_SET, &qdev->flags); in ql_mpi_idc_work()
1188 status = ql_mb_idc_ack(qdev); in ql_mpi_idc_work()
1190 netif_err(qdev, drv, qdev->ndev, in ql_mpi_idc_work()
1193 netif_printk(qdev, drv, KERN_DEBUG, qdev->ndev, in ql_mpi_idc_work()
1210 ql_link_off(qdev); in ql_mpi_idc_work()
1211 set_bit(QL_CAM_RT_SET, &qdev->flags); in ql_mpi_idc_work()
1221 status = ql_mb_idc_ack(qdev); in ql_mpi_idc_work()
1223 netif_err(qdev, drv, qdev->ndev, in ql_mpi_idc_work()
1226 netif_printk(qdev, drv, KERN_DEBUG, qdev->ndev, in ql_mpi_idc_work()
1236 struct ql_adapter *qdev = in ql_mpi_work() local
1242 mutex_lock(&qdev->mpi_mutex); in ql_mpi_work()
1244 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16)); in ql_mpi_work()
1246 while (ql_read32(qdev, STS) & STS_PI) { in ql_mpi_work()
1252 err = ql_mpi_handler(qdev, mbcp); in ql_mpi_work()
1258 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16) | INTR_MASK_PI); in ql_mpi_work()
1259 mutex_unlock(&qdev->mpi_mutex); in ql_mpi_work()
1260 ql_enable_completion_interrupt(qdev, 0); in ql_mpi_work()
1265 struct ql_adapter *qdev = in ql_mpi_reset_work() local
1267 cancel_delayed_work_sync(&qdev->mpi_work); in ql_mpi_reset_work()
1268 cancel_delayed_work_sync(&qdev->mpi_port_cfg_work); in ql_mpi_reset_work()
1269 cancel_delayed_work_sync(&qdev->mpi_idc_work); in ql_mpi_reset_work()
1273 if (!ql_own_firmware(qdev)) { in ql_mpi_reset_work()
1274 netif_err(qdev, drv, qdev->ndev, "Don't own firmware!\n"); in ql_mpi_reset_work()
1278 if (qdev->mpi_coredump && !ql_core_dump(qdev, qdev->mpi_coredump)) { in ql_mpi_reset_work()
1279 netif_err(qdev, drv, qdev->ndev, "Core is dumped!\n"); in ql_mpi_reset_work()
1280 qdev->core_is_dumped = 1; in ql_mpi_reset_work()
1281 queue_delayed_work(qdev->workqueue, in ql_mpi_reset_work()
1282 &qdev->mpi_core_to_log, 5 * HZ); in ql_mpi_reset_work()
1284 ql_soft_reset_mpi_risc(qdev); in ql_mpi_reset_work()