Lines Matching full:cmdq
31 static void bfa_msgq_cmdq_dbell(struct bfa_msgq_cmdq *cmdq);
32 static void bfa_msgq_cmdq_copy_rsp(struct bfa_msgq_cmdq *cmdq);
43 bfa_fsm_state_decl(cmdq, stopped, struct bfa_msgq_cmdq, enum cmdq_event);
44 bfa_fsm_state_decl(cmdq, init_wait, struct bfa_msgq_cmdq, enum cmdq_event);
45 bfa_fsm_state_decl(cmdq, ready, struct bfa_msgq_cmdq, enum cmdq_event);
46 bfa_fsm_state_decl(cmdq, dbell_wait, struct bfa_msgq_cmdq,
50 cmdq_sm_stopped_entry(struct bfa_msgq_cmdq *cmdq) in cmdq_sm_stopped_entry() argument
54 cmdq->producer_index = 0; in cmdq_sm_stopped_entry()
55 cmdq->consumer_index = 0; in cmdq_sm_stopped_entry()
56 cmdq->flags = 0; in cmdq_sm_stopped_entry()
57 cmdq->token = 0; in cmdq_sm_stopped_entry()
58 cmdq->offset = 0; in cmdq_sm_stopped_entry()
59 cmdq->bytes_to_copy = 0; in cmdq_sm_stopped_entry()
60 while (!list_empty(&cmdq->pending_q)) { in cmdq_sm_stopped_entry()
61 cmdq_ent = list_first_entry(&cmdq->pending_q, in cmdq_sm_stopped_entry()
69 cmdq_sm_stopped(struct bfa_msgq_cmdq *cmdq, enum cmdq_event event) in cmdq_sm_stopped() argument
73 bfa_fsm_set_state(cmdq, cmdq_sm_init_wait); in cmdq_sm_stopped()
82 cmdq->flags |= BFA_MSGQ_CMDQ_F_DB_UPDATE; in cmdq_sm_stopped()
91 cmdq_sm_init_wait_entry(struct bfa_msgq_cmdq *cmdq) in cmdq_sm_init_wait_entry() argument
93 bfa_wc_down(&cmdq->msgq->init_wc); in cmdq_sm_init_wait_entry()
97 cmdq_sm_init_wait(struct bfa_msgq_cmdq *cmdq, enum cmdq_event event) in cmdq_sm_init_wait() argument
102 bfa_fsm_set_state(cmdq, cmdq_sm_stopped); in cmdq_sm_init_wait()
106 cmdq->flags |= BFA_MSGQ_CMDQ_F_DB_UPDATE; in cmdq_sm_init_wait()
110 if (cmdq->flags & BFA_MSGQ_CMDQ_F_DB_UPDATE) { in cmdq_sm_init_wait()
111 cmdq->flags &= ~BFA_MSGQ_CMDQ_F_DB_UPDATE; in cmdq_sm_init_wait()
112 bfa_fsm_set_state(cmdq, cmdq_sm_dbell_wait); in cmdq_sm_init_wait()
114 bfa_fsm_set_state(cmdq, cmdq_sm_ready); in cmdq_sm_init_wait()
123 cmdq_sm_ready_entry(struct bfa_msgq_cmdq *cmdq) in cmdq_sm_ready_entry() argument
128 cmdq_sm_ready(struct bfa_msgq_cmdq *cmdq, enum cmdq_event event) in cmdq_sm_ready() argument
133 bfa_fsm_set_state(cmdq, cmdq_sm_stopped); in cmdq_sm_ready()
137 bfa_fsm_set_state(cmdq, cmdq_sm_dbell_wait); in cmdq_sm_ready()
146 cmdq_sm_dbell_wait_entry(struct bfa_msgq_cmdq *cmdq) in cmdq_sm_dbell_wait_entry() argument
148 bfa_msgq_cmdq_dbell(cmdq); in cmdq_sm_dbell_wait_entry()
152 cmdq_sm_dbell_wait(struct bfa_msgq_cmdq *cmdq, enum cmdq_event event) in cmdq_sm_dbell_wait() argument
157 bfa_fsm_set_state(cmdq, cmdq_sm_stopped); in cmdq_sm_dbell_wait()
161 cmdq->flags |= BFA_MSGQ_CMDQ_F_DB_UPDATE; in cmdq_sm_dbell_wait()
165 if (cmdq->flags & BFA_MSGQ_CMDQ_F_DB_UPDATE) { in cmdq_sm_dbell_wait()
166 cmdq->flags &= ~BFA_MSGQ_CMDQ_F_DB_UPDATE; in cmdq_sm_dbell_wait()
167 bfa_fsm_set_state(cmdq, cmdq_sm_dbell_wait); in cmdq_sm_dbell_wait()
169 bfa_fsm_set_state(cmdq, cmdq_sm_ready); in cmdq_sm_dbell_wait()
180 struct bfa_msgq_cmdq *cmdq = (struct bfa_msgq_cmdq *)arg; in bfa_msgq_cmdq_dbell_ready() local
181 bfa_fsm_send_event(cmdq, CMDQ_E_DB_READY); in bfa_msgq_cmdq_dbell_ready()
185 bfa_msgq_cmdq_dbell(struct bfa_msgq_cmdq *cmdq) in bfa_msgq_cmdq_dbell() argument
188 (struct bfi_msgq_h2i_db *)(&cmdq->dbell_mb.msg[0]); in bfa_msgq_cmdq_dbell()
193 dbell->idx.cmdq_pi = htons(cmdq->producer_index); in bfa_msgq_cmdq_dbell()
195 if (!bfa_nw_ioc_mbox_queue(cmdq->msgq->ioc, &cmdq->dbell_mb, in bfa_msgq_cmdq_dbell()
196 bfa_msgq_cmdq_dbell_ready, cmdq)) { in bfa_msgq_cmdq_dbell()
197 bfa_msgq_cmdq_dbell_ready(cmdq); in bfa_msgq_cmdq_dbell()
202 __cmd_copy(struct bfa_msgq_cmdq *cmdq, struct bfa_msgq_cmd_entry *cmd) in __cmd_copy() argument
209 dst = (u8 *)cmdq->addr.kva; in __cmd_copy()
210 dst += (cmdq->producer_index * BFI_MSGQ_CMD_ENTRY_SIZE); in __cmd_copy()
218 BFA_MSGQ_INDX_ADD(cmdq->producer_index, 1, cmdq->depth); in __cmd_copy()
219 dst = (u8 *)cmdq->addr.kva; in __cmd_copy()
220 dst += (cmdq->producer_index * BFI_MSGQ_CMD_ENTRY_SIZE); in __cmd_copy()
226 bfa_msgq_cmdq_ci_update(struct bfa_msgq_cmdq *cmdq, struct bfi_mbmsg *mb) in bfa_msgq_cmdq_ci_update() argument
232 cmdq->consumer_index = ntohs(dbell->idx.cmdq_ci); in bfa_msgq_cmdq_ci_update()
235 while (!list_empty(&cmdq->pending_q)) { in bfa_msgq_cmdq_ci_update()
236 cmd = list_first_entry(&cmdq->pending_q, in bfa_msgq_cmdq_ci_update()
239 BFA_MSGQ_FREE_CNT(cmdq)) { in bfa_msgq_cmdq_ci_update()
241 __cmd_copy(cmdq, cmd); in bfa_msgq_cmdq_ci_update()
250 bfa_fsm_send_event(cmdq, CMDQ_E_POST); in bfa_msgq_cmdq_ci_update()
256 struct bfa_msgq_cmdq *cmdq = (struct bfa_msgq_cmdq *)arg; in bfa_msgq_cmdq_copy_next() local
258 if (cmdq->bytes_to_copy) in bfa_msgq_cmdq_copy_next()
259 bfa_msgq_cmdq_copy_rsp(cmdq); in bfa_msgq_cmdq_copy_next()
263 bfa_msgq_cmdq_copy_req(struct bfa_msgq_cmdq *cmdq, struct bfi_mbmsg *mb) in bfa_msgq_cmdq_copy_req() argument
268 cmdq->token = 0; in bfa_msgq_cmdq_copy_req()
269 cmdq->offset = ntohs(req->offset); in bfa_msgq_cmdq_copy_req()
270 cmdq->bytes_to_copy = ntohs(req->len); in bfa_msgq_cmdq_copy_req()
271 bfa_msgq_cmdq_copy_rsp(cmdq); in bfa_msgq_cmdq_copy_req()
275 bfa_msgq_cmdq_copy_rsp(struct bfa_msgq_cmdq *cmdq) in bfa_msgq_cmdq_copy_rsp() argument
278 (struct bfi_msgq_h2i_cmdq_copy_rsp *)&cmdq->copy_mb.msg[0]; in bfa_msgq_cmdq_copy_rsp()
280 u8 *addr = (u8 *)cmdq->addr.kva; in bfa_msgq_cmdq_copy_rsp()
284 rsp->mh.mtag.i2htok = htons(cmdq->token); in bfa_msgq_cmdq_copy_rsp()
285 copied = (cmdq->bytes_to_copy >= BFI_CMD_COPY_SZ) ? BFI_CMD_COPY_SZ : in bfa_msgq_cmdq_copy_rsp()
286 cmdq->bytes_to_copy; in bfa_msgq_cmdq_copy_rsp()
287 addr += cmdq->offset; in bfa_msgq_cmdq_copy_rsp()
290 cmdq->token++; in bfa_msgq_cmdq_copy_rsp()
291 cmdq->offset += copied; in bfa_msgq_cmdq_copy_rsp()
292 cmdq->bytes_to_copy -= copied; in bfa_msgq_cmdq_copy_rsp()
294 if (!bfa_nw_ioc_mbox_queue(cmdq->msgq->ioc, &cmdq->copy_mb, in bfa_msgq_cmdq_copy_rsp()
295 bfa_msgq_cmdq_copy_next, cmdq)) { in bfa_msgq_cmdq_copy_rsp()
296 bfa_msgq_cmdq_copy_next(cmdq); in bfa_msgq_cmdq_copy_rsp()
301 bfa_msgq_cmdq_attach(struct bfa_msgq_cmdq *cmdq, struct bfa_msgq *msgq) in bfa_msgq_cmdq_attach() argument
303 cmdq->depth = BFA_MSGQ_CMDQ_NUM_ENTRY; in bfa_msgq_cmdq_attach()
304 INIT_LIST_HEAD(&cmdq->pending_q); in bfa_msgq_cmdq_attach()
305 cmdq->msgq = msgq; in bfa_msgq_cmdq_attach()
306 bfa_fsm_set_state(cmdq, cmdq_sm_stopped); in bfa_msgq_cmdq_attach()
500 bfa_fsm_send_event(&msgq->cmdq, CMDQ_E_INIT_RESP); in bfa_msgq_init_rsp()
515 bfa_dma_be_addr_set(msgq_cfg->cmdq.addr, msgq->cmdq.addr.pa); in bfa_msgq_init()
516 msgq_cfg->cmdq.q_depth = htons(msgq->cmdq.depth); in bfa_msgq_init()
538 bfa_msgq_cmdq_ci_update(&msgq->cmdq, msg); in bfa_msgq_isr()
542 bfa_msgq_cmdq_copy_req(&msgq->cmdq, msg); in bfa_msgq_isr()
559 bfa_fsm_send_event(&msgq->cmdq, CMDQ_E_START); in bfa_msgq_notify()
566 bfa_fsm_send_event(&msgq->cmdq, CMDQ_E_STOP); in bfa_msgq_notify()
571 bfa_fsm_send_event(&msgq->cmdq, CMDQ_E_FAIL); in bfa_msgq_notify()
590 msgq->cmdq.addr.kva = kva; in bfa_msgq_memclaim()
591 msgq->cmdq.addr.pa = pa; in bfa_msgq_memclaim()
605 bfa_msgq_cmdq_attach(&msgq->cmdq, msgq); in bfa_msgq_attach()
625 BFA_MSGQ_FREE_CNT(&msgq->cmdq)) { in bfa_msgq_cmd_post()
626 __cmd_copy(&msgq->cmdq, cmd); in bfa_msgq_cmd_post()
628 bfa_fsm_send_event(&msgq->cmdq, CMDQ_E_POST); in bfa_msgq_cmd_post()
630 list_add_tail(&cmd->qe, &msgq->cmdq.pending_q); in bfa_msgq_cmd_post()