Lines Matching refs:hr_dev
41 static int hns_roce_cmd_mbox_post_hw(struct hns_roce_dev *hr_dev, in hns_roce_cmd_mbox_post_hw() argument
44 return hr_dev->hw->post_mbox(hr_dev, mbox_msg); in hns_roce_cmd_mbox_post_hw()
48 static int __hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, in __hns_roce_cmd_mbox_poll() argument
53 ret = hns_roce_cmd_mbox_post_hw(hr_dev, mbox_msg); in __hns_roce_cmd_mbox_poll()
55 dev_err_ratelimited(hr_dev->dev, in __hns_roce_cmd_mbox_poll()
61 return hr_dev->hw->poll_mbox_done(hr_dev); in __hns_roce_cmd_mbox_poll()
64 static int hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, in hns_roce_cmd_mbox_poll() argument
69 down(&hr_dev->cmd.poll_sem); in hns_roce_cmd_mbox_poll()
70 ret = __hns_roce_cmd_mbox_poll(hr_dev, mbox_msg); in hns_roce_cmd_mbox_poll()
71 up(&hr_dev->cmd.poll_sem); in hns_roce_cmd_mbox_poll()
76 void hns_roce_cmd_event(struct hns_roce_dev *hr_dev, u16 token, u8 status, in hns_roce_cmd_event() argument
80 &hr_dev->cmd.context[token % hr_dev->cmd.max_cmds]; in hns_roce_cmd_event()
83 dev_err_ratelimited(hr_dev->dev, in hns_roce_cmd_event()
94 static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, in __hns_roce_cmd_mbox_wait() argument
97 struct hns_roce_cmdq *cmd = &hr_dev->cmd; in __hns_roce_cmd_mbox_wait()
99 struct device *dev = hr_dev->dev; in __hns_roce_cmd_mbox_wait()
117 ret = hns_roce_cmd_mbox_post_hw(hr_dev, mbox_msg); in __hns_roce_cmd_mbox_wait()
143 static int hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, in hns_roce_cmd_mbox_wait() argument
148 down(&hr_dev->cmd.event_sem); in hns_roce_cmd_mbox_wait()
149 ret = __hns_roce_cmd_mbox_wait(hr_dev, mbox_msg); in hns_roce_cmd_mbox_wait()
150 up(&hr_dev->cmd.event_sem); in hns_roce_cmd_mbox_wait()
155 int hns_roce_cmd_mbox(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param, in hns_roce_cmd_mbox() argument
161 if (hr_dev->hw->chk_mbox_avail) in hns_roce_cmd_mbox()
162 if (!hr_dev->hw->chk_mbox_avail(hr_dev, &is_busy)) in hns_roce_cmd_mbox()
170 if (hr_dev->cmd.use_events) { in hns_roce_cmd_mbox()
173 return hns_roce_cmd_mbox_wait(hr_dev, &mbox_msg); in hns_roce_cmd_mbox()
178 return hns_roce_cmd_mbox_poll(hr_dev, &mbox_msg); in hns_roce_cmd_mbox()
182 int hns_roce_cmd_init(struct hns_roce_dev *hr_dev) in hns_roce_cmd_init() argument
184 sema_init(&hr_dev->cmd.poll_sem, 1); in hns_roce_cmd_init()
185 hr_dev->cmd.use_events = 0; in hns_roce_cmd_init()
186 hr_dev->cmd.max_cmds = CMD_MAX_NUM; in hns_roce_cmd_init()
187 hr_dev->cmd.pool = dma_pool_create("hns_roce_cmd", hr_dev->dev, in hns_roce_cmd_init()
190 if (!hr_dev->cmd.pool) in hns_roce_cmd_init()
196 void hns_roce_cmd_cleanup(struct hns_roce_dev *hr_dev) in hns_roce_cmd_cleanup() argument
198 dma_pool_destroy(hr_dev->cmd.pool); in hns_roce_cmd_cleanup()
201 int hns_roce_cmd_use_events(struct hns_roce_dev *hr_dev) in hns_roce_cmd_use_events() argument
203 struct hns_roce_cmdq *hr_cmd = &hr_dev->cmd; in hns_roce_cmd_use_events()
209 hr_dev->cmd_mod = 0; in hns_roce_cmd_use_events()
229 void hns_roce_cmd_use_polling(struct hns_roce_dev *hr_dev) in hns_roce_cmd_use_polling() argument
231 struct hns_roce_cmdq *hr_cmd = &hr_dev->cmd; in hns_roce_cmd_use_polling()
238 hns_roce_alloc_cmd_mailbox(struct hns_roce_dev *hr_dev) in hns_roce_alloc_cmd_mailbox() argument
247 dma_pool_alloc(hr_dev->cmd.pool, GFP_KERNEL, &mailbox->dma); in hns_roce_alloc_cmd_mailbox()
256 void hns_roce_free_cmd_mailbox(struct hns_roce_dev *hr_dev, in hns_roce_free_cmd_mailbox() argument
262 dma_pool_free(hr_dev->cmd.pool, mailbox->buf, mailbox->dma); in hns_roce_free_cmd_mailbox()