Lines Matching refs:dt

122 static void dma_test_free_rings(struct dma_test *dt)  in dma_test_free_rings()  argument
124 if (dt->rx_ring) { in dma_test_free_rings()
125 tb_xdomain_release_in_hopid(dt->xd, dt->rx_hopid); in dma_test_free_rings()
126 tb_ring_free(dt->rx_ring); in dma_test_free_rings()
127 dt->rx_ring = NULL; in dma_test_free_rings()
129 if (dt->tx_ring) { in dma_test_free_rings()
130 tb_xdomain_release_out_hopid(dt->xd, dt->tx_hopid); in dma_test_free_rings()
131 tb_ring_free(dt->tx_ring); in dma_test_free_rings()
132 dt->tx_ring = NULL; in dma_test_free_rings()
136 static int dma_test_start_rings(struct dma_test *dt) in dma_test_start_rings() argument
139 struct tb_xdomain *xd = dt->xd; in dma_test_start_rings()
148 if (dt->packets_to_send && dt->packets_to_receive) in dma_test_start_rings()
151 if (dt->packets_to_send) { in dma_test_start_rings()
157 dt->tx_ring = ring; in dma_test_start_rings()
162 dma_test_free_rings(dt); in dma_test_start_rings()
166 dt->tx_hopid = ret; in dma_test_start_rings()
169 if (dt->packets_to_receive) { in dma_test_start_rings()
179 dma_test_free_rings(dt); in dma_test_start_rings()
183 dt->rx_ring = ring; in dma_test_start_rings()
187 dma_test_free_rings(dt); in dma_test_start_rings()
191 dt->rx_hopid = ret; in dma_test_start_rings()
194 ret = tb_xdomain_enable_paths(dt->xd, dt->tx_hopid, in dma_test_start_rings()
195 dt->tx_ring ? dt->tx_ring->hop : 0, in dma_test_start_rings()
196 dt->rx_hopid, in dma_test_start_rings()
197 dt->rx_ring ? dt->rx_ring->hop : 0); in dma_test_start_rings()
199 dma_test_free_rings(dt); in dma_test_start_rings()
203 if (dt->tx_ring) in dma_test_start_rings()
204 tb_ring_start(dt->tx_ring); in dma_test_start_rings()
205 if (dt->rx_ring) in dma_test_start_rings()
206 tb_ring_start(dt->rx_ring); in dma_test_start_rings()
211 static void dma_test_stop_rings(struct dma_test *dt) in dma_test_stop_rings() argument
215 if (dt->rx_ring) in dma_test_stop_rings()
216 tb_ring_stop(dt->rx_ring); in dma_test_stop_rings()
217 if (dt->tx_ring) in dma_test_stop_rings()
218 tb_ring_stop(dt->tx_ring); in dma_test_stop_rings()
220 ret = tb_xdomain_disable_paths(dt->xd, dt->tx_hopid, in dma_test_stop_rings()
221 dt->tx_ring ? dt->tx_ring->hop : 0, in dma_test_stop_rings()
222 dt->rx_hopid, in dma_test_stop_rings()
223 dt->rx_ring ? dt->rx_ring->hop : 0); in dma_test_stop_rings()
225 dev_warn(&dt->svc->dev, "failed to disable DMA paths\n"); in dma_test_stop_rings()
227 dma_test_free_rings(dt); in dma_test_stop_rings()
234 struct dma_test *dt = tf->dma_test; in dma_test_rx_callback() local
235 struct device *dma_dev = tb_ring_dma_device(dt->rx_ring); in dma_test_rx_callback()
246 dt->packets_received++; in dma_test_rx_callback()
247 dev_dbg(&dt->svc->dev, "packet %u/%u received\n", dt->packets_received, in dma_test_rx_callback()
248 dt->packets_to_receive); in dma_test_rx_callback()
251 dt->crc_errors++; in dma_test_rx_callback()
253 dt->buffer_overflow_errors++; in dma_test_rx_callback()
257 if (dt->packets_received == dt->packets_to_receive) in dma_test_rx_callback()
258 complete(&dt->complete); in dma_test_rx_callback()
261 static int dma_test_submit_rx(struct dma_test *dt, size_t npackets) in dma_test_submit_rx() argument
263 struct device *dma_dev = tb_ring_dma_device(dt->rx_ring); in dma_test_submit_rx()
290 tf->dma_test = dt; in dma_test_submit_rx()
293 tb_ring_rx(dt->rx_ring, &tf->frame); in dma_test_submit_rx()
303 struct dma_test *dt = tf->dma_test; in dma_test_tx_callback() local
304 struct device *dma_dev = tb_ring_dma_device(dt->tx_ring); in dma_test_tx_callback()
312 static int dma_test_submit_tx(struct dma_test *dt, size_t npackets) in dma_test_submit_tx() argument
314 struct device *dma_dev = tb_ring_dma_device(dt->tx_ring); in dma_test_submit_tx()
326 tf->dma_test = dt; in dma_test_submit_tx()
348 dt->packets_sent++; in dma_test_submit_tx()
349 dev_dbg(&dt->svc->dev, "packet %u/%u sent\n", dt->packets_sent, in dma_test_submit_tx()
350 dt->packets_to_send); in dma_test_submit_tx()
352 tb_ring_tx(dt->tx_ring, &tf->frame); in dma_test_submit_tx()
362 struct dma_test *dt = tb_service_get_drvdata(svc); \
365 ret = mutex_lock_interruptible(&dt->lock); \
368 __get(dt, val); \
369 mutex_unlock(&dt->lock); \
375 struct dma_test *dt = tb_service_get_drvdata(svc); \
381 ret = mutex_lock_interruptible(&dt->lock); \
384 __set(dt, val); \
385 mutex_unlock(&dt->lock); \
391 static void lanes_get(const struct dma_test *dt, u64 *val) in lanes_get() argument
393 *val = dt->link_width; in lanes_get()
401 static void lanes_set(struct dma_test *dt, u64 val) in lanes_set() argument
403 dt->link_width = val; in lanes_set()
407 static void speed_get(const struct dma_test *dt, u64 *val) in speed_get() argument
409 *val = dt->link_speed; in speed_get()
424 static void speed_set(struct dma_test *dt, u64 val) in speed_set() argument
426 dt->link_speed = val; in speed_set()
430 static void packets_to_receive_get(const struct dma_test *dt, u64 *val) in packets_to_receive_get() argument
432 *val = dt->packets_to_receive; in packets_to_receive_get()
440 static void packets_to_receive_set(struct dma_test *dt, u64 val) in packets_to_receive_set() argument
442 dt->packets_to_receive = val; in packets_to_receive_set()
447 static void packets_to_send_get(const struct dma_test *dt, u64 *val) in packets_to_send_get() argument
449 *val = dt->packets_to_send; in packets_to_send_get()
457 static void packets_to_send_set(struct dma_test *dt, u64 val) in packets_to_send_set() argument
459 dt->packets_to_send = val; in packets_to_send_set()
464 static int dma_test_set_bonding(struct dma_test *dt) in dma_test_set_bonding() argument
466 switch (dt->link_width) { in dma_test_set_bonding()
468 return tb_xdomain_lane_bonding_enable(dt->xd); in dma_test_set_bonding()
470 tb_xdomain_lane_bonding_disable(dt->xd); in dma_test_set_bonding()
477 static bool dma_test_validate_config(struct dma_test *dt) in dma_test_validate_config() argument
479 if (!dt->packets_to_send && !dt->packets_to_receive) in dma_test_validate_config()
481 if (dt->packets_to_send && dt->packets_to_receive && in dma_test_validate_config()
482 dt->packets_to_send != dt->packets_to_receive) in dma_test_validate_config()
487 static void dma_test_check_errors(struct dma_test *dt, int ret) in dma_test_check_errors() argument
489 if (!dt->error_code) { in dma_test_check_errors()
490 if (dt->link_speed && dt->xd->link_speed != dt->link_speed) { in dma_test_check_errors()
491 dt->error_code = DMA_TEST_SPEED_ERROR; in dma_test_check_errors()
492 } else if (dt->link_width && in dma_test_check_errors()
493 dt->xd->link_width != dt->link_width) { in dma_test_check_errors()
494 dt->error_code = DMA_TEST_WIDTH_ERROR; in dma_test_check_errors()
495 } else if (dt->packets_to_send != dt->packets_sent || in dma_test_check_errors()
496 dt->packets_to_receive != dt->packets_received || in dma_test_check_errors()
497 dt->crc_errors || dt->buffer_overflow_errors) { in dma_test_check_errors()
498 dt->error_code = DMA_TEST_PACKET_ERROR; in dma_test_check_errors()
504 dt->result = DMA_TEST_FAIL; in dma_test_check_errors()
510 struct dma_test *dt = tb_service_get_drvdata(svc); in test_store() local
516 ret = mutex_lock_interruptible(&dt->lock); in test_store()
520 dt->packets_sent = 0; in test_store()
521 dt->packets_received = 0; in test_store()
522 dt->crc_errors = 0; in test_store()
523 dt->buffer_overflow_errors = 0; in test_store()
524 dt->result = DMA_TEST_SUCCESS; in test_store()
525 dt->error_code = DMA_TEST_NO_ERROR; in test_store()
528 if (dt->link_speed) in test_store()
529 dev_dbg(&svc->dev, "link_speed: %u Gb/s\n", dt->link_speed); in test_store()
530 if (dt->link_width) in test_store()
531 dev_dbg(&svc->dev, "link_width: %u\n", dt->link_width); in test_store()
532 dev_dbg(&svc->dev, "packets_to_send: %u\n", dt->packets_to_send); in test_store()
533 dev_dbg(&svc->dev, "packets_to_receive: %u\n", dt->packets_to_receive); in test_store()
535 if (!dma_test_validate_config(dt)) { in test_store()
537 dt->error_code = DMA_TEST_CONFIG_ERROR; in test_store()
541 ret = dma_test_set_bonding(dt); in test_store()
544 dt->error_code = DMA_TEST_BONDING_ERROR; in test_store()
548 ret = dma_test_start_rings(dt); in test_store()
551 dt->error_code = DMA_TEST_DMA_ERROR; in test_store()
555 if (dt->packets_to_receive) { in test_store()
556 reinit_completion(&dt->complete); in test_store()
557 ret = dma_test_submit_rx(dt, dt->packets_to_receive); in test_store()
560 dt->error_code = DMA_TEST_BUFFER_ERROR; in test_store()
565 if (dt->packets_to_send) { in test_store()
566 ret = dma_test_submit_tx(dt, dt->packets_to_send); in test_store()
569 dt->error_code = DMA_TEST_BUFFER_ERROR; in test_store()
574 if (dt->packets_to_receive) { in test_store()
575 ret = wait_for_completion_interruptible(&dt->complete); in test_store()
577 dt->error_code = DMA_TEST_INTERRUPTED; in test_store()
583 dma_test_stop_rings(dt); in test_store()
585 dma_test_check_errors(dt, ret); in test_store()
586 mutex_unlock(&dt->lock); in test_store()
588 dev_dbg(&svc->dev, "DMA test %s\n", dma_test_result_names[dt->result]); in test_store()
596 struct dma_test *dt = tb_service_get_drvdata(svc); in status_show() local
599 ret = mutex_lock_interruptible(&dt->lock); in status_show()
603 seq_printf(s, "result: %s\n", dma_test_result_names[dt->result]); in status_show()
604 if (dt->result == DMA_TEST_NOT_RUN) in status_show()
607 seq_printf(s, "packets received: %u\n", dt->packets_received); in status_show()
608 seq_printf(s, "packets sent: %u\n", dt->packets_sent); in status_show()
609 seq_printf(s, "CRC errors: %u\n", dt->crc_errors); in status_show()
611 dt->buffer_overflow_errors); in status_show()
612 seq_printf(s, "error: %s\n", dma_test_error_names[dt->error_code]); in status_show()
615 mutex_unlock(&dt->lock); in status_show()
622 struct dma_test *dt = tb_service_get_drvdata(svc); in dma_test_debugfs_init() local
624 dt->debugfs_dir = debugfs_create_dir("dma_test", svc->debugfs_dir); in dma_test_debugfs_init()
626 debugfs_create_file("lanes", 0600, dt->debugfs_dir, svc, &lanes_fops); in dma_test_debugfs_init()
627 debugfs_create_file("speed", 0600, dt->debugfs_dir, svc, &speed_fops); in dma_test_debugfs_init()
628 debugfs_create_file("packets_to_receive", 0600, dt->debugfs_dir, svc, in dma_test_debugfs_init()
630 debugfs_create_file("packets_to_send", 0600, dt->debugfs_dir, svc, in dma_test_debugfs_init()
632 debugfs_create_file("status", 0400, dt->debugfs_dir, svc, &status_fops); in dma_test_debugfs_init()
633 debugfs_create_file("test", 0200, dt->debugfs_dir, svc, &test_fops); in dma_test_debugfs_init()
639 struct dma_test *dt; in dma_test_probe() local
641 dt = devm_kzalloc(&svc->dev, sizeof(*dt), GFP_KERNEL); in dma_test_probe()
642 if (!dt) in dma_test_probe()
645 dt->svc = svc; in dma_test_probe()
646 dt->xd = xd; in dma_test_probe()
647 mutex_init(&dt->lock); in dma_test_probe()
648 init_completion(&dt->complete); in dma_test_probe()
650 tb_service_set_drvdata(svc, dt); in dma_test_probe()
658 struct dma_test *dt = tb_service_get_drvdata(svc); in dma_test_remove() local
660 mutex_lock(&dt->lock); in dma_test_remove()
661 debugfs_remove_recursive(dt->debugfs_dir); in dma_test_remove()
662 mutex_unlock(&dt->lock); in dma_test_remove()