Lines Matching +full:- +full:lp

47 ldc_rx_ctrl(struct ldc_conn *lc, struct ldc_pkt *lp)  in ldc_rx_ctrl()  argument
49 switch (lp->ctrl) { in ldc_rx_ctrl()
51 ldc_rx_ctrl_vers(lc, lp); in ldc_rx_ctrl()
55 ldc_rx_ctrl_rts(lc, lp); in ldc_rx_ctrl()
59 ldc_rx_ctrl_rtr(lc, lp); in ldc_rx_ctrl()
63 ldc_rx_ctrl_rdx(lc, lp); in ldc_rx_ctrl()
67 DPRINTF(("CTRL/0x%02x/0x%02x\n", lp->stype, lp->ctrl)); in ldc_rx_ctrl()
74 ldc_rx_ctrl_vers(struct ldc_conn *lc, struct ldc_pkt *lp) in ldc_rx_ctrl_vers() argument
76 switch (lp->stype) { in ldc_rx_ctrl_vers()
78 DPRINTF(("CTRL/INFO/VERS major %d minor %d\n", lp->major, lp->minor)); in ldc_rx_ctrl_vers()
79 if (lp->major == LDC_VERSION_MAJOR && in ldc_rx_ctrl_vers()
80 lp->minor == LDC_VERSION_MINOR) in ldc_rx_ctrl_vers()
90 if (lc->lc_state != LDC_SND_VERS) { in ldc_rx_ctrl_vers()
92 lc->lc_state, lp->major, lp->minor)); in ldc_rx_ctrl_vers()
105 DPRINTF(("CTRL/0x%02x/VERS\n", lp->stype)); in ldc_rx_ctrl_vers()
112 ldc_rx_ctrl_rts(struct ldc_conn *lc, struct ldc_pkt *lp) in ldc_rx_ctrl_rts() argument
114 switch (lp->stype) { in ldc_rx_ctrl_rts()
116 if (lc->lc_state != LDC_RCV_VERS) { in ldc_rx_ctrl_rts()
118 lc->lc_state)); in ldc_rx_ctrl_rts()
137 DPRINTF(("CTRL/0x%02x/RTS\n", lp->stype)); in ldc_rx_ctrl_rts()
144 ldc_rx_ctrl_rtr(struct ldc_conn *lc, struct ldc_pkt *lp) in ldc_rx_ctrl_rtr() argument
146 switch (lp->stype) { in ldc_rx_ctrl_rtr()
148 if (lc->lc_state != LDC_SND_RTS) { in ldc_rx_ctrl_rtr()
150 lc->lc_state)); in ldc_rx_ctrl_rtr()
156 lc->lc_start(lc); in ldc_rx_ctrl_rtr()
170 DPRINTF(("CTRL/0x%02x/RTR\n", lp->stype)); in ldc_rx_ctrl_rtr()
177 ldc_rx_ctrl_rdx(struct ldc_conn *lc, struct ldc_pkt *lp) in ldc_rx_ctrl_rdx() argument
179 switch (lp->stype) { in ldc_rx_ctrl_rdx()
181 if (lc->lc_state != LDC_SND_RTR) { in ldc_rx_ctrl_rdx()
183 lc->lc_state)); in ldc_rx_ctrl_rdx()
188 lc->lc_start(lc); in ldc_rx_ctrl_rdx()
202 DPRINTF(("CTRL/0x%02x/RDX\n", lp->stype)); in ldc_rx_ctrl_rdx()
209 ldc_rx_data(struct ldc_conn *lc, struct ldc_pkt *lp) in ldc_rx_data() argument
213 if (lp->stype != LDC_INFO) { in ldc_rx_data()
214 DPRINTF(("DATA/0x%02x\n", lp->stype)); in ldc_rx_data()
219 if (lc->lc_state != LDC_SND_RTR && in ldc_rx_data()
220 lc->lc_state != LDC_SND_RDX) { in ldc_rx_data()
221 DPRINTF(("Spurious DATA/INFO: state %d\n", lc->lc_state)); in ldc_rx_data()
226 if (lp->env & LDC_FRAG_START) { in ldc_rx_data()
227 lc->lc_len = (lp->env & LDC_LEN_MASK) + 8; in ldc_rx_data()
228 KASSERT(lc->lc_len <= sizeof(lc->lc_msg)); in ldc_rx_data()
229 memcpy((uint8_t *)lc->lc_msg, lp, lc->lc_len); in ldc_rx_data()
231 len = (lp->env & LDC_LEN_MASK); in ldc_rx_data()
232 if (lc->lc_len + len > sizeof(lc->lc_msg)) { in ldc_rx_data()
237 memcpy(((uint8_t *)lc->lc_msg) + lc->lc_len, &lp->major, len); in ldc_rx_data()
238 lc->lc_len += len; in ldc_rx_data()
241 if (lp->env & LDC_FRAG_STOP) in ldc_rx_data()
242 lc->lc_rx_data(lc, (struct ldc_pkt *)lc->lc_msg); in ldc_rx_data()
248 struct ldc_pkt *lp; in ldc_send_vers() local
252 mutex_enter(&lc->lc_txq->lq_mtx); in ldc_send_vers()
253 err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state); in ldc_send_vers()
255 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_vers()
259 lp = (struct ldc_pkt *)(uintptr_t)(lc->lc_txq->lq_va + tx_tail); in ldc_send_vers()
260 bzero(lp, sizeof(struct ldc_pkt)); in ldc_send_vers()
261 lp->type = LDC_CTRL; in ldc_send_vers()
262 lp->stype = LDC_INFO; in ldc_send_vers()
263 lp->ctrl = LDC_VERS; in ldc_send_vers()
264 lp->major = 1; in ldc_send_vers()
265 lp->minor = 0; in ldc_send_vers()
266 DPRINTF(("ldc_send_vers() major %d minor %d\n", lp->major, lp->minor)); in ldc_send_vers()
268 tx_tail += sizeof(*lp); in ldc_send_vers()
269 tx_tail &= ((lc->lc_txq->lq_nentries * sizeof(*lp)) - 1); in ldc_send_vers()
270 err = hv_ldc_tx_set_qtail(lc->lc_id, tx_tail); in ldc_send_vers()
273 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_vers()
277 lc->lc_state = LDC_SND_VERS; in ldc_send_vers()
278 DPRINTF(("ldc_send_vers() setting lc->lc_state to %d\n", lc->lc_state)); in ldc_send_vers()
279 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_vers()
285 struct ldc_pkt *lp; in ldc_send_ack() local
289 mutex_enter(&lc->lc_txq->lq_mtx); in ldc_send_ack()
290 err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state); in ldc_send_ack()
292 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_ack()
296 lp = (struct ldc_pkt *)(uintptr_t)(lc->lc_txq->lq_va + tx_tail); in ldc_send_ack()
297 bzero(lp, sizeof(struct ldc_pkt)); in ldc_send_ack()
298 lp->type = LDC_CTRL; in ldc_send_ack()
299 lp->stype = LDC_ACK; in ldc_send_ack()
300 lp->ctrl = LDC_VERS; in ldc_send_ack()
301 lp->major = 1; in ldc_send_ack()
302 lp->minor = 0; in ldc_send_ack()
304 tx_tail += sizeof(*lp); in ldc_send_ack()
305 tx_tail &= ((lc->lc_txq->lq_nentries * sizeof(*lp)) - 1); in ldc_send_ack()
306 err = hv_ldc_tx_set_qtail(lc->lc_id, tx_tail); in ldc_send_ack()
309 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_ack()
313 lc->lc_state = LDC_RCV_VERS; in ldc_send_ack()
314 DPRINTF(("ldc_send_ack() setting lc->lc_state to %d\n", lc->lc_state)); in ldc_send_ack()
315 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_ack()
321 struct ldc_pkt *lp; in ldc_send_rts() local
325 mutex_enter(&lc->lc_txq->lq_mtx); in ldc_send_rts()
326 err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state); in ldc_send_rts()
328 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_rts()
332 lp = (struct ldc_pkt *)(uintptr_t)(lc->lc_txq->lq_va + tx_tail); in ldc_send_rts()
333 bzero(lp, sizeof(struct ldc_pkt)); in ldc_send_rts()
334 lp->type = LDC_CTRL; in ldc_send_rts()
335 lp->stype = LDC_INFO; in ldc_send_rts()
336 lp->ctrl = LDC_RTS; in ldc_send_rts()
337 lp->env = LDC_MODE_UNRELIABLE; in ldc_send_rts()
338 lp->seqid = lc->lc_tx_seqid++; in ldc_send_rts()
340 tx_tail += sizeof(*lp); in ldc_send_rts()
341 tx_tail &= ((lc->lc_txq->lq_nentries * sizeof(*lp)) - 1); in ldc_send_rts()
342 err = hv_ldc_tx_set_qtail(lc->lc_id, tx_tail); in ldc_send_rts()
345 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_rts()
349 lc->lc_state = LDC_SND_RTS; in ldc_send_rts()
350 DPRINTF(("ldc_send_rts() setting lc->lc_state to %d\n", lc->lc_state)); in ldc_send_rts()
351 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_rts()
357 struct ldc_pkt *lp; in ldc_send_rtr() local
361 mutex_enter(&lc->lc_txq->lq_mtx); in ldc_send_rtr()
362 err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state); in ldc_send_rtr()
364 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_rtr()
368 lp = (struct ldc_pkt *)(uintptr_t)(lc->lc_txq->lq_va + tx_tail); in ldc_send_rtr()
369 bzero(lp, sizeof(struct ldc_pkt)); in ldc_send_rtr()
370 lp->type = LDC_CTRL; in ldc_send_rtr()
371 lp->stype = LDC_INFO; in ldc_send_rtr()
372 lp->ctrl = LDC_RTR; in ldc_send_rtr()
373 lp->env = LDC_MODE_UNRELIABLE; in ldc_send_rtr()
374 lp->seqid = lc->lc_tx_seqid++; in ldc_send_rtr()
376 tx_tail += sizeof(*lp); in ldc_send_rtr()
377 tx_tail &= ((lc->lc_txq->lq_nentries * sizeof(*lp)) - 1); in ldc_send_rtr()
378 err = hv_ldc_tx_set_qtail(lc->lc_id, tx_tail); in ldc_send_rtr()
381 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_rtr()
385 lc->lc_state = LDC_SND_RTR; in ldc_send_rtr()
386 DPRINTF(("ldc_send_rtr() setting lc->lc_state to %d\n", lc->lc_state)); in ldc_send_rtr()
387 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_rtr()
393 struct ldc_pkt *lp; in ldc_send_rdx() local
397 mutex_enter(&lc->lc_txq->lq_mtx); in ldc_send_rdx()
398 err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state); in ldc_send_rdx()
400 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_rdx()
404 lp = (struct ldc_pkt *)(uintptr_t)(lc->lc_txq->lq_va + tx_tail); in ldc_send_rdx()
405 bzero(lp, sizeof(struct ldc_pkt)); in ldc_send_rdx()
406 lp->type = LDC_CTRL; in ldc_send_rdx()
407 lp->stype = LDC_INFO; in ldc_send_rdx()
408 lp->ctrl = LDC_RDX; in ldc_send_rdx()
409 lp->env = LDC_MODE_UNRELIABLE; in ldc_send_rdx()
410 lp->seqid = lc->lc_tx_seqid++; in ldc_send_rdx()
412 tx_tail += sizeof(*lp); in ldc_send_rdx()
413 tx_tail &= ((lc->lc_txq->lq_nentries * sizeof(*lp)) - 1); in ldc_send_rdx()
414 err = hv_ldc_tx_set_qtail(lc->lc_id, tx_tail); in ldc_send_rdx()
417 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_rdx()
421 lc->lc_state = LDC_SND_RDX; in ldc_send_rdx()
422 DPRINTF(("ldc_send_rdx() setting lc->lc_state to %d\n", lc->lc_state)); in ldc_send_rdx()
423 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_rdx()
429 struct ldc_pkt *lp; in ldc_send_unreliable() local
435 mutex_enter(&lc->lc_txq->lq_mtx); in ldc_send_unreliable()
436 err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state); in ldc_send_unreliable()
438 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_unreliable()
442 tx_avail = (tx_head - tx_tail) / sizeof(*lp) + in ldc_send_unreliable()
443 lc->lc_txq->lq_nentries - 1; in ldc_send_unreliable()
444 tx_avail %= lc->lc_txq->lq_nentries; in ldc_send_unreliable()
446 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_unreliable()
451 lp = (struct ldc_pkt *)(uintptr_t)(lc->lc_txq->lq_va + tx_tail); in ldc_send_unreliable()
452 bzero(lp, sizeof(struct ldc_pkt)); in ldc_send_unreliable()
453 lp->type = LDC_DATA; in ldc_send_unreliable()
454 lp->stype = LDC_INFO; in ldc_send_unreliable()
455 lp->env = uimin(len, LDC_PKT_PAYLOAD); in ldc_send_unreliable()
457 lp->env |= LDC_FRAG_START; in ldc_send_unreliable()
459 lp->env |= LDC_FRAG_STOP; in ldc_send_unreliable()
460 lp->seqid = lc->lc_tx_seqid++; in ldc_send_unreliable()
461 bcopy(p, &lp->major, uimin(len, LDC_PKT_PAYLOAD)); in ldc_send_unreliable()
463 tx_tail += sizeof(*lp); in ldc_send_unreliable()
464 tx_tail &= ((lc->lc_txq->lq_nentries * sizeof(*lp)) - 1); in ldc_send_unreliable()
465 err = hv_ldc_tx_set_qtail(lc->lc_id, tx_tail); in ldc_send_unreliable()
468 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_unreliable()
472 len -= uimin(len, LDC_PKT_PAYLOAD); in ldc_send_unreliable()
475 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_send_unreliable()
488 mutex_enter(&lc->lc_txq->lq_mtx); in ldc_reset()
491 err = hv_ldc_tx_qconf(lc->lc_id, in ldc_reset()
492 lc->lc_txq->lq_map->dm_segs[0].ds_addr, lc->lc_txq->lq_nentries); in ldc_reset()
494 va = lc->lc_txq->lq_va; in ldc_reset()
498 err = hv_ldc_tx_qconf(lc->lc_id, pa, lc->lc_txq->lq_nentries); in ldc_reset()
504 err = hv_ldc_rx_qconf(lc->lc_id, in ldc_reset()
505 lc->lc_rxq->lq_map->dm_segs[0].ds_addr, lc->lc_rxq->lq_nentries); in ldc_reset()
507 va = lc->lc_rxq->lq_va; in ldc_reset()
511 err = hv_ldc_tx_qconf(lc->lc_id, pa, lc->lc_rxq->lq_nentries); in ldc_reset()
516 lc->lc_tx_seqid = 0; in ldc_reset()
517 lc->lc_state = 0; in ldc_reset()
518 lc->lc_tx_state = lc->lc_rx_state = LDC_CHANNEL_DOWN; in ldc_reset()
519 mutex_exit(&lc->lc_txq->lq_mtx); in ldc_reset()
521 lc->lc_reset(lc); in ldc_reset()
540 mutex_init(&lq->lq_mtx, MUTEX_DEFAULT, IPL_TTY); in ldc_queue_alloc()
545 BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &lq->lq_map) != 0) in ldc_queue_alloc()
548 if (bus_dmamem_alloc(t, size, PAGE_SIZE, 0, &lq->lq_seg, 1, in ldc_queue_alloc()
552 if (bus_dmamem_map(t, &lq->lq_seg, 1, size, (void *)&va, in ldc_queue_alloc()
556 if (bus_dmamap_load(t, lq->lq_map, (void*)va, size, NULL, in ldc_queue_alloc()
562 lq->lq_va = (vaddr_t)va; in ldc_queue_alloc()
563 lq->lq_nentries = nentries; in ldc_queue_alloc()
569 bus_dmamem_free(t, &lq->lq_seg, 1); in ldc_queue_alloc()
571 bus_dmamap_destroy(t, lq->lq_map); in ldc_queue_alloc()
585 size = roundup(lq->lq_nentries * sizeof(struct ldc_pkt), PAGE_SIZE); in ldc_queue_free()
588 bus_dmamap_unload(t, lq->lq_map); in ldc_queue_free()
589 bus_dmamem_unmap(t, &lq->lq_va, size); in ldc_queue_free()
590 bus_dmamem_free(t, &lq->lq_seg, 1); in ldc_queue_free()
591 bus_dmamap_destroy(t, lq->lq_map); in ldc_queue_free()
593 kmem_free((void *)lq->lq_va, size); in ldc_queue_free()
618 BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &lm->lm_map) != 0) { in ldc_map_alloc()
619 DPRINTF(("ldc_map_alloc() - bus_dmamap_create() failed\n")); in ldc_map_alloc()
623 if (bus_dmamem_alloc(t, size, PAGE_SIZE, 0, &lm->lm_seg, 1, in ldc_map_alloc()
625 DPRINTF(("ldc_map_alloc() - bus_dmamem_alloc() failed\n")); in ldc_map_alloc()
629 if (bus_dmamem_map(t, &lm->lm_seg, 1, size, (void *)&va, in ldc_map_alloc()
631 DPRINTF(("ldc_map_alloc() - bus_dmamem_map() failed\n")); in ldc_map_alloc()
634 if (bus_dmamap_load(t, lm->lm_map, (void*)va, size, NULL, in ldc_map_alloc()
636 DPRINTF(("ldc_map_alloc() - bus_dmamap_load() failed\n")); in ldc_map_alloc()
642 lm->lm_slot = (struct ldc_map_slot *)va; in ldc_map_alloc()
643 lm->lm_nentries = nentries; in ldc_map_alloc()
644 bzero(lm->lm_slot, nentries * sizeof(struct ldc_map_slot)); in ldc_map_alloc()
651 bus_dmamem_free(t, &lm->lm_seg, 1); in ldc_map_alloc()
653 bus_dmamap_destroy(t, lm->lm_map); in ldc_map_alloc()
668 size = lm->lm_nentries * sizeof(struct ldc_map_slot); in ldc_map_free()
672 bus_dmamap_unload(t, lm->lm_map); in ldc_map_free()
673 bus_dmamem_unmap(t, lm->lm_slot, size); in ldc_map_free()
674 bus_dmamem_free(t, &lm->lm_seg, 1); in ldc_map_free()
675 bus_dmamap_destroy(t, lm->lm_map); in ldc_map_free()
677 kmem_free(lm->lm_slot, size); in ldc_map_free()