Lines Matching refs:cmd

260 	return (swab32(status) >> 31) != priv->cmd.comm_toggle;  in comm_pending()
263 static int mlx4_comm_cmd_post(struct mlx4_dev *dev, u8 cmd, u16 param) in mlx4_comm_cmd_post() argument
280 priv->cmd.comm_toggle ^= 1; in mlx4_comm_cmd_post()
281 val = param | (cmd << 16) | (priv->cmd.comm_toggle << 31); in mlx4_comm_cmd_post()
288 static int mlx4_comm_cmd_poll(struct mlx4_dev *dev, u8 cmd, u16 param, in mlx4_comm_cmd_poll() argument
299 priv->cmd.comm_toggle, cmd); in mlx4_comm_cmd_poll()
304 down(&priv->cmd.poll_sem); in mlx4_comm_cmd_poll()
305 if (mlx4_comm_cmd_post(dev, cmd, param)) { in mlx4_comm_cmd_poll()
321 if ((MLX4_COMM_CMD_RESET == cmd)) { in mlx4_comm_cmd_poll()
326 cmd); in mlx4_comm_cmd_poll()
334 up(&priv->cmd.poll_sem); in mlx4_comm_cmd_poll()
341 struct mlx4_cmd *cmd = &mlx4_priv(dev)->cmd; in mlx4_comm_cmd_wait() local
346 down(&cmd->event_sem); in mlx4_comm_cmd_wait()
348 spin_lock(&cmd->context_lock); in mlx4_comm_cmd_wait()
349 BUG_ON(cmd->free_head < 0); in mlx4_comm_cmd_wait()
350 context = &cmd->context[cmd->free_head]; in mlx4_comm_cmd_wait()
351 context->token += cmd->token_mask + 1; in mlx4_comm_cmd_wait()
352 cmd->free_head = context->next; in mlx4_comm_cmd_wait()
353 spin_unlock(&cmd->context_lock); in mlx4_comm_cmd_wait()
398 spin_lock(&cmd->context_lock); in mlx4_comm_cmd_wait()
399 context->next = cmd->free_head; in mlx4_comm_cmd_wait()
400 cmd->free_head = context - cmd->context; in mlx4_comm_cmd_wait()
401 spin_unlock(&cmd->context_lock); in mlx4_comm_cmd_wait()
403 up(&cmd->event_sem); in mlx4_comm_cmd_wait()
407 int mlx4_comm_cmd(struct mlx4_dev *dev, u8 cmd, u16 param, in mlx4_comm_cmd() argument
413 if (mlx4_priv(dev)->cmd.use_events) in mlx4_comm_cmd()
414 return mlx4_comm_cmd_wait(dev, cmd, param, op, timeout); in mlx4_comm_cmd()
415 return mlx4_comm_cmd_poll(dev, cmd, param, timeout); in mlx4_comm_cmd()
425 status = readl(mlx4_priv(dev)->cmd.hcr + HCR_STATUS_OFFSET); in cmd_pending()
428 (mlx4_priv(dev)->cmd.toggle == in cmd_pending()
436 struct mlx4_cmd *cmd = &mlx4_priv(dev)->cmd; in mlx4_cmd_post() local
437 u32 __iomem *hcr = cmd->hcr; in mlx4_cmd_post()
493 (cmd->toggle << HCR_T_BIT) | in mlx4_cmd_post()
498 cmd->toggle = cmd->toggle ^ 1; in mlx4_cmd_post()
519 mutex_lock(&priv->cmd.slave_cmd_mutex); in mlx4_slave_cmd()
527 vhcr->flags = !!(priv->cmd.use_events) << 6; in mlx4_slave_cmd()
572 mutex_unlock(&priv->cmd.slave_cmd_mutex); in mlx4_slave_cmd()
581 void __iomem *hcr = priv->cmd.hcr; in mlx4_cmd_poll()
586 down(&priv->cmd.poll_sem); in mlx4_cmd_poll()
656 up(&priv->cmd.poll_sem); in mlx4_cmd_poll()
664 &priv->cmd.context[token & priv->cmd.token_mask]; in mlx4_cmd_event()
681 struct mlx4_cmd *cmd = &mlx4_priv(dev)->cmd; in mlx4_cmd_wait() local
686 down(&cmd->event_sem); in mlx4_cmd_wait()
688 spin_lock(&cmd->context_lock); in mlx4_cmd_wait()
689 BUG_ON(cmd->free_head < 0); in mlx4_cmd_wait()
690 context = &cmd->context[cmd->free_head]; in mlx4_cmd_wait()
691 context->token += cmd->token_mask + 1; in mlx4_cmd_wait()
692 cmd->free_head = context->next; in mlx4_cmd_wait()
693 spin_unlock(&cmd->context_lock); in mlx4_cmd_wait()
765 spin_lock(&cmd->context_lock); in mlx4_cmd_wait()
766 context->next = cmd->free_head; in mlx4_cmd_wait()
767 cmd->free_head = context - cmd->context; in mlx4_cmd_wait()
768 spin_unlock(&cmd->context_lock); in mlx4_cmd_wait()
770 up(&cmd->event_sem); in mlx4_cmd_wait()
787 down_read(&mlx4_priv(dev)->cmd.switch_sem); in __mlx4_cmd()
788 if (mlx4_priv(dev)->cmd.use_events) in __mlx4_cmd()
797 up_read(&mlx4_priv(dev)->cmd.switch_sem); in __mlx4_cmd()
895 struct mlx4_cmd_info *cmd) in mlx4_MAD_IFC_wrapper() argument
1029 struct mlx4_cmd_info *cmd) in mlx4_CMD_EPERM_wrapper() argument
1038 struct mlx4_cmd_info *cmd) in mlx4_DMA_wrapper() argument
1044 in_param = cmd->has_inbox ? (u64) inbox->dma : vhcr->in_param; in mlx4_DMA_wrapper()
1045 out_param = cmd->has_outbox ? (u64) outbox->dma : vhcr->out_param; in mlx4_DMA_wrapper()
1046 if (cmd->encode_slave_id) { in mlx4_DMA_wrapper()
1051 err = __mlx4_cmd(dev, in_param, &out_param, cmd->out_is_imm, in mlx4_DMA_wrapper()
1055 if (cmd->out_is_imm) in mlx4_DMA_wrapper()
1665 struct mlx4_cmd_info *cmd = NULL; in mlx4_master_process_vhcr() local
1709 cmd = &cmd_info[i]; in mlx4_master_process_vhcr()
1713 if (!cmd) { in mlx4_master_process_vhcr()
1721 if (cmd->has_inbox) { in mlx4_master_process_vhcr()
1737 __func__, cmd->opcode); in mlx4_master_process_vhcr()
1744 if (cmd->verify && cmd->verify(dev, slave, vhcr, inbox)) { in mlx4_master_process_vhcr()
1752 if (cmd->has_outbox) { in mlx4_master_process_vhcr()
1762 if (cmd->wrapper) { in mlx4_master_process_vhcr()
1763 err = cmd->wrapper(dev, slave, vhcr, inbox, outbox, in mlx4_master_process_vhcr()
1764 cmd); in mlx4_master_process_vhcr()
1765 if (cmd->out_is_imm) in mlx4_master_process_vhcr()
1768 in_param = cmd->has_inbox ? (u64) inbox->dma : in mlx4_master_process_vhcr()
1770 out_param = cmd->has_outbox ? (u64) outbox->dma : in mlx4_master_process_vhcr()
1773 cmd->out_is_imm, vhcr->in_modifier, in mlx4_master_process_vhcr()
1778 if (cmd->out_is_imm) { in mlx4_master_process_vhcr()
1802 if (cmd->has_outbox && !vhcr_cmd->status) { in mlx4_master_process_vhcr()
2084 static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd, in mlx4_master_do_cmd() argument
2101 if (cmd == MLX4_COMM_CMD_RESET) { in mlx4_master_do_cmd()
2124 if (cmd != MLX4_COMM_CMD_RESET && in mlx4_master_do_cmd()
2127 slave, cmd); in mlx4_master_do_cmd()
2131 switch (cmd) { in mlx4_master_do_cmd()
2161 slave, cmd, slave_state[slave].last_cmd); in mlx4_master_do_cmd()
2165 mutex_lock(&priv->cmd.slave_cmd_mutex); in mlx4_master_do_cmd()
2169 mutex_unlock(&priv->cmd.slave_cmd_mutex); in mlx4_master_do_cmd()
2172 mutex_unlock(&priv->cmd.slave_cmd_mutex); in mlx4_master_do_cmd()
2175 mlx4_warn(dev, "Bad comm cmd:%d from slave:%d\n", cmd, slave); in mlx4_master_do_cmd()
2180 slave_state[slave].last_cmd = cmd; in mlx4_master_do_cmd()
2186 cmd, slave); in mlx4_master_do_cmd()
2199 if (cmd != MLX4_COMM_CMD_RESET) { in mlx4_master_do_cmd()
2201 slave, cmd); in mlx4_master_do_cmd()
2324 priv->cmd.comm_toggle = rd_toggle >> 31; in sync_toggles()
2340 priv->cmd.comm_toggle = 0; in sync_toggles()
2499 if (!priv->cmd.initialized) { in mlx4_cmd_init()
2500 init_rwsem(&priv->cmd.switch_sem); in mlx4_cmd_init()
2501 mutex_init(&priv->cmd.slave_cmd_mutex); in mlx4_cmd_init()
2502 sema_init(&priv->cmd.poll_sem, 1); in mlx4_cmd_init()
2503 priv->cmd.use_events = 0; in mlx4_cmd_init()
2504 priv->cmd.toggle = 1; in mlx4_cmd_init()
2505 priv->cmd.initialized = 1; in mlx4_cmd_init()
2509 if (!mlx4_is_slave(dev) && !priv->cmd.hcr) { in mlx4_cmd_init()
2510 priv->cmd.hcr = ioremap(pci_resource_start(dev->persist->pdev, in mlx4_cmd_init()
2512 if (!priv->cmd.hcr) { in mlx4_cmd_init()
2530 if (!priv->cmd.pool) { in mlx4_cmd_init()
2531 priv->cmd.pool = dma_pool_create("mlx4_cmd", in mlx4_cmd_init()
2535 if (!priv->cmd.pool) in mlx4_cmd_init()
2597 if (priv->cmd.pool && (cleanup_mask & MLX4_CMD_CLEANUP_POOL)) { in mlx4_cmd_cleanup()
2598 dma_pool_destroy(priv->cmd.pool); in mlx4_cmd_cleanup()
2599 priv->cmd.pool = NULL; in mlx4_cmd_cleanup()
2602 if (!mlx4_is_slave(dev) && priv->cmd.hcr && in mlx4_cmd_cleanup()
2604 iounmap(priv->cmd.hcr); in mlx4_cmd_cleanup()
2605 priv->cmd.hcr = NULL; in mlx4_cmd_cleanup()
2613 if (priv->cmd.initialized && (cleanup_mask & MLX4_CMD_CLEANUP_STRUCT)) in mlx4_cmd_cleanup()
2614 priv->cmd.initialized = 0; in mlx4_cmd_cleanup()
2627 priv->cmd.context = kmalloc_array(priv->cmd.max_cmds, in mlx4_cmd_use_events()
2630 if (!priv->cmd.context) in mlx4_cmd_use_events()
2634 mutex_lock(&priv->cmd.slave_cmd_mutex); in mlx4_cmd_use_events()
2635 down_write(&priv->cmd.switch_sem); in mlx4_cmd_use_events()
2636 for (i = 0; i < priv->cmd.max_cmds; ++i) { in mlx4_cmd_use_events()
2637 priv->cmd.context[i].token = i; in mlx4_cmd_use_events()
2638 priv->cmd.context[i].next = i + 1; in mlx4_cmd_use_events()
2643 init_completion(&priv->cmd.context[i].done); in mlx4_cmd_use_events()
2646 priv->cmd.context[priv->cmd.max_cmds - 1].next = -1; in mlx4_cmd_use_events()
2647 priv->cmd.free_head = 0; in mlx4_cmd_use_events()
2649 sema_init(&priv->cmd.event_sem, priv->cmd.max_cmds); in mlx4_cmd_use_events()
2651 for (priv->cmd.token_mask = 1; in mlx4_cmd_use_events()
2652 priv->cmd.token_mask < priv->cmd.max_cmds; in mlx4_cmd_use_events()
2653 priv->cmd.token_mask <<= 1) in mlx4_cmd_use_events()
2655 --priv->cmd.token_mask; in mlx4_cmd_use_events()
2657 down(&priv->cmd.poll_sem); in mlx4_cmd_use_events()
2658 priv->cmd.use_events = 1; in mlx4_cmd_use_events()
2659 up_write(&priv->cmd.switch_sem); in mlx4_cmd_use_events()
2661 mutex_unlock(&priv->cmd.slave_cmd_mutex); in mlx4_cmd_use_events()
2675 mutex_lock(&priv->cmd.slave_cmd_mutex); in mlx4_cmd_use_polling()
2676 down_write(&priv->cmd.switch_sem); in mlx4_cmd_use_polling()
2677 priv->cmd.use_events = 0; in mlx4_cmd_use_polling()
2679 for (i = 0; i < priv->cmd.max_cmds; ++i) in mlx4_cmd_use_polling()
2680 down(&priv->cmd.event_sem); in mlx4_cmd_use_polling()
2682 kfree(priv->cmd.context); in mlx4_cmd_use_polling()
2683 priv->cmd.context = NULL; in mlx4_cmd_use_polling()
2685 up(&priv->cmd.poll_sem); in mlx4_cmd_use_polling()
2686 up_write(&priv->cmd.switch_sem); in mlx4_cmd_use_polling()
2688 mutex_unlock(&priv->cmd.slave_cmd_mutex); in mlx4_cmd_use_polling()
2699 mailbox->buf = dma_pool_zalloc(mlx4_priv(dev)->cmd.pool, GFP_KERNEL, in mlx4_alloc_cmd_mailbox()
2716 dma_pool_free(mlx4_priv(dev)->cmd.pool, mailbox->buf, mailbox->dma); in mlx4_free_cmd_mailbox()
2754 spin_lock(&priv->cmd.context_lock); in mlx4_cmd_wake_completions()
2755 if (priv->cmd.context) { in mlx4_cmd_wake_completions()
2756 for (i = 0; i < priv->cmd.max_cmds; ++i) { in mlx4_cmd_wake_completions()
2757 context = &priv->cmd.context[i]; in mlx4_cmd_wake_completions()
2764 spin_unlock(&priv->cmd.context_lock); in mlx4_cmd_wake_completions()