Lines Matching refs:fifo
86 struct mlxbf_tmfifo *fifo; member
137 struct mlxbf_tmfifo *fifo; member
227 static void mlxbf_tmfifo_free_vrings(struct mlxbf_tmfifo *fifo, in mlxbf_tmfifo_free_vrings() argument
249 static int mlxbf_tmfifo_alloc_vrings(struct mlxbf_tmfifo *fifo, in mlxbf_tmfifo_alloc_vrings() argument
260 vring->fifo = fifo; in mlxbf_tmfifo_alloc_vrings()
270 mlxbf_tmfifo_free_vrings(fifo, tm_vdev); in mlxbf_tmfifo_alloc_vrings()
283 static void mlxbf_tmfifo_disable_irqs(struct mlxbf_tmfifo *fifo) in mlxbf_tmfifo_disable_irqs() argument
288 irq = fifo->irq_info[i].irq; in mlxbf_tmfifo_disable_irqs()
289 fifo->irq_info[i].irq = 0; in mlxbf_tmfifo_disable_irqs()
299 if (!test_and_set_bit(irq_info->index, &irq_info->fifo->pend_events)) in mlxbf_tmfifo_irq_handler()
300 schedule_work(&irq_info->fifo->work); in mlxbf_tmfifo_irq_handler()
420 struct mlxbf_tmfifo *fifo = container_of(t, struct mlxbf_tmfifo, timer); in mlxbf_tmfifo_timer() local
423 rx = !test_and_set_bit(MLXBF_TM_RX_HWM_IRQ, &fifo->pend_events); in mlxbf_tmfifo_timer()
424 tx = !test_and_set_bit(MLXBF_TM_TX_LWM_IRQ, &fifo->pend_events); in mlxbf_tmfifo_timer()
427 schedule_work(&fifo->work); in mlxbf_tmfifo_timer()
429 mod_timer(&fifo->timer, jiffies + MLXBF_TMFIFO_TIMER_INTERVAL); in mlxbf_tmfifo_timer()
490 static int mlxbf_tmfifo_get_rx_avail(struct mlxbf_tmfifo *fifo) in mlxbf_tmfifo_get_rx_avail() argument
494 sts = readq(fifo->rx.sts); in mlxbf_tmfifo_get_rx_avail()
499 static int mlxbf_tmfifo_get_tx_avail(struct mlxbf_tmfifo *fifo, int vdev_id) in mlxbf_tmfifo_get_tx_avail() argument
507 tx_reserve = fifo->tx_fifo_size / MLXBF_TMFIFO_RESERVE_RATIO; in mlxbf_tmfifo_get_tx_avail()
511 sts = readq(fifo->tx.sts); in mlxbf_tmfifo_get_tx_avail()
513 return fifo->tx_fifo_size - tx_reserve - count; in mlxbf_tmfifo_get_tx_avail()
517 static void mlxbf_tmfifo_console_tx(struct mlxbf_tmfifo *fifo, int avail) in mlxbf_tmfifo_console_tx() argument
530 cons = fifo->vdev[VIRTIO_ID_CONSOLE]; in mlxbf_tmfifo_console_tx()
547 writeq(*(u64 *)&hdr, fifo->tx.data); in mlxbf_tmfifo_console_tx()
550 spin_lock_irqsave(&fifo->spin_lock[0], flags); in mlxbf_tmfifo_console_tx()
564 writeq(data, fifo->tx.data); in mlxbf_tmfifo_console_tx()
577 spin_unlock_irqrestore(&fifo->spin_lock[0], flags); in mlxbf_tmfifo_console_tx()
586 struct mlxbf_tmfifo *fifo = vring->fifo; in mlxbf_tmfifo_rxtx_word() local
595 data = readq(fifo->rx.data); in mlxbf_tmfifo_rxtx_word()
617 writeq(data, fifo->tx.data); in mlxbf_tmfifo_rxtx_word()
631 struct mlxbf_tmfifo *fifo = vring->fifo; in mlxbf_tmfifo_rxtx_header() local
639 *(u64 *)&hdr = readq(fifo->rx.data); in mlxbf_tmfifo_rxtx_header()
649 config = &fifo->vdev[vdev_id]->config.net; in mlxbf_tmfifo_rxtx_header()
666 struct mlxbf_tmfifo_vdev *tm_dev2 = fifo->vdev[vdev_id]; in mlxbf_tmfifo_rxtx_header()
683 writeq(*(u64 *)&hdr, fifo->tx.data); in mlxbf_tmfifo_rxtx_header()
688 fifo->vring[is_rx] = vring; in mlxbf_tmfifo_rxtx_header()
700 struct mlxbf_tmfifo *fifo = vring->fifo; in mlxbf_tmfifo_rxtx_one_desc() local
707 vdev = &fifo->vdev[vring->vdev_id]->vdev; in mlxbf_tmfifo_rxtx_one_desc()
756 fifo->vring[is_rx] = NULL; in mlxbf_tmfifo_rxtx_one_desc()
765 spin_lock_irqsave(&fifo->spin_lock[is_rx], flags); in mlxbf_tmfifo_rxtx_one_desc()
767 spin_unlock_irqrestore(&fifo->spin_lock[is_rx], flags); in mlxbf_tmfifo_rxtx_one_desc()
781 struct mlxbf_tmfifo *fifo; in mlxbf_tmfifo_rxtx() local
784 fifo = vring->fifo; in mlxbf_tmfifo_rxtx()
787 if (!fifo->vdev[devid]) in mlxbf_tmfifo_rxtx()
791 if (fifo->vring[is_rx] && fifo->vring[is_rx] != vring) in mlxbf_tmfifo_rxtx()
802 avail = mlxbf_tmfifo_get_rx_avail(fifo); in mlxbf_tmfifo_rxtx()
804 avail = mlxbf_tmfifo_get_tx_avail(fifo, devid); in mlxbf_tmfifo_rxtx()
811 mlxbf_tmfifo_console_tx(fifo, avail); in mlxbf_tmfifo_rxtx()
821 static void mlxbf_tmfifo_work_rxtx(struct mlxbf_tmfifo *fifo, int queue_id, in mlxbf_tmfifo_work_rxtx() argument
828 if (!test_and_clear_bit(irq_id, &fifo->pend_events) || in mlxbf_tmfifo_work_rxtx()
829 !fifo->irq_info[irq_id].irq) in mlxbf_tmfifo_work_rxtx()
833 tm_vdev = fifo->vdev[i]; in mlxbf_tmfifo_work_rxtx()
845 struct mlxbf_tmfifo *fifo; in mlxbf_tmfifo_work_handler() local
847 fifo = container_of(work, struct mlxbf_tmfifo, work); in mlxbf_tmfifo_work_handler()
848 if (!fifo->is_ready) in mlxbf_tmfifo_work_handler()
851 mutex_lock(&fifo->lock); in mlxbf_tmfifo_work_handler()
854 mlxbf_tmfifo_work_rxtx(fifo, MLXBF_TMFIFO_VRING_TX, in mlxbf_tmfifo_work_handler()
858 mlxbf_tmfifo_work_rxtx(fifo, MLXBF_TMFIFO_VRING_RX, in mlxbf_tmfifo_work_handler()
861 mutex_unlock(&fifo->lock); in mlxbf_tmfifo_work_handler()
869 struct mlxbf_tmfifo *fifo; in mlxbf_tmfifo_virtio_notify() local
872 fifo = vring->fifo; in mlxbf_tmfifo_virtio_notify()
886 spin_lock_irqsave(&fifo->spin_lock[0], flags); in mlxbf_tmfifo_virtio_notify()
887 tm_vdev = fifo->vdev[VIRTIO_ID_CONSOLE]; in mlxbf_tmfifo_virtio_notify()
889 spin_unlock_irqrestore(&fifo->spin_lock[0], flags); in mlxbf_tmfifo_virtio_notify()
891 &fifo->pend_events)) { in mlxbf_tmfifo_virtio_notify()
895 if (test_and_set_bit(MLXBF_TM_RX_HWM_IRQ, &fifo->pend_events)) in mlxbf_tmfifo_virtio_notify()
899 schedule_work(&fifo->work); in mlxbf_tmfifo_virtio_notify()
1072 struct mlxbf_tmfifo *fifo, in mlxbf_tmfifo_create_vdev() argument
1079 mutex_lock(&fifo->lock); in mlxbf_tmfifo_create_vdev()
1081 tm_vdev = fifo->vdev[vdev_id]; in mlxbf_tmfifo_create_vdev()
1102 if (mlxbf_tmfifo_alloc_vrings(fifo, tm_vdev)) { in mlxbf_tmfifo_create_vdev()
1113 fifo->vdev[vdev_id] = tm_vdev; in mlxbf_tmfifo_create_vdev()
1123 mutex_unlock(&fifo->lock); in mlxbf_tmfifo_create_vdev()
1127 mlxbf_tmfifo_free_vrings(fifo, tm_vdev); in mlxbf_tmfifo_create_vdev()
1128 fifo->vdev[vdev_id] = NULL; in mlxbf_tmfifo_create_vdev()
1134 mutex_unlock(&fifo->lock); in mlxbf_tmfifo_create_vdev()
1139 static int mlxbf_tmfifo_delete_vdev(struct mlxbf_tmfifo *fifo, int vdev_id) in mlxbf_tmfifo_delete_vdev() argument
1143 mutex_lock(&fifo->lock); in mlxbf_tmfifo_delete_vdev()
1146 tm_vdev = fifo->vdev[vdev_id]; in mlxbf_tmfifo_delete_vdev()
1149 mlxbf_tmfifo_free_vrings(fifo, tm_vdev); in mlxbf_tmfifo_delete_vdev()
1150 fifo->vdev[vdev_id] = NULL; in mlxbf_tmfifo_delete_vdev()
1153 mutex_unlock(&fifo->lock); in mlxbf_tmfifo_delete_vdev()
1174 static void mlxbf_tmfifo_set_threshold(struct mlxbf_tmfifo *fifo) in mlxbf_tmfifo_set_threshold() argument
1179 ctl = readq(fifo->tx.ctl); in mlxbf_tmfifo_set_threshold()
1180 fifo->tx_fifo_size = in mlxbf_tmfifo_set_threshold()
1184 fifo->tx_fifo_size / 2); in mlxbf_tmfifo_set_threshold()
1187 fifo->tx_fifo_size - 1); in mlxbf_tmfifo_set_threshold()
1188 writeq(ctl, fifo->tx.ctl); in mlxbf_tmfifo_set_threshold()
1191 ctl = readq(fifo->rx.ctl); in mlxbf_tmfifo_set_threshold()
1192 fifo->rx_fifo_size = in mlxbf_tmfifo_set_threshold()
1198 writeq(ctl, fifo->rx.ctl); in mlxbf_tmfifo_set_threshold()
1201 static void mlxbf_tmfifo_cleanup(struct mlxbf_tmfifo *fifo) in mlxbf_tmfifo_cleanup() argument
1205 fifo->is_ready = false; in mlxbf_tmfifo_cleanup()
1206 del_timer_sync(&fifo->timer); in mlxbf_tmfifo_cleanup()
1207 mlxbf_tmfifo_disable_irqs(fifo); in mlxbf_tmfifo_cleanup()
1208 cancel_work_sync(&fifo->work); in mlxbf_tmfifo_cleanup()
1210 mlxbf_tmfifo_delete_vdev(fifo, i); in mlxbf_tmfifo_cleanup()
1218 struct mlxbf_tmfifo *fifo; in mlxbf_tmfifo_probe() local
1228 fifo = devm_kzalloc(dev, sizeof(*fifo), GFP_KERNEL); in mlxbf_tmfifo_probe()
1229 if (!fifo) in mlxbf_tmfifo_probe()
1232 spin_lock_init(&fifo->spin_lock[0]); in mlxbf_tmfifo_probe()
1233 spin_lock_init(&fifo->spin_lock[1]); in mlxbf_tmfifo_probe()
1234 INIT_WORK(&fifo->work, mlxbf_tmfifo_work_handler); in mlxbf_tmfifo_probe()
1235 mutex_init(&fifo->lock); in mlxbf_tmfifo_probe()
1238 fifo->res0 = devm_platform_ioremap_resource(pdev, 0); in mlxbf_tmfifo_probe()
1239 if (IS_ERR(fifo->res0)) in mlxbf_tmfifo_probe()
1240 return PTR_ERR(fifo->res0); in mlxbf_tmfifo_probe()
1243 fifo->res1 = devm_platform_ioremap_resource(pdev, 1); in mlxbf_tmfifo_probe()
1244 if (IS_ERR(fifo->res1)) in mlxbf_tmfifo_probe()
1245 return PTR_ERR(fifo->res1); in mlxbf_tmfifo_probe()
1248 fifo->rx.ctl = fifo->res1 + MLXBF_TMFIFO_RX_CTL_BF3; in mlxbf_tmfifo_probe()
1249 fifo->rx.sts = fifo->res1 + MLXBF_TMFIFO_RX_STS_BF3; in mlxbf_tmfifo_probe()
1250 fifo->rx.data = fifo->res0 + MLXBF_TMFIFO_RX_DATA_BF3; in mlxbf_tmfifo_probe()
1251 fifo->tx.ctl = fifo->res1 + MLXBF_TMFIFO_TX_CTL_BF3; in mlxbf_tmfifo_probe()
1252 fifo->tx.sts = fifo->res1 + MLXBF_TMFIFO_TX_STS_BF3; in mlxbf_tmfifo_probe()
1253 fifo->tx.data = fifo->res0 + MLXBF_TMFIFO_TX_DATA_BF3; in mlxbf_tmfifo_probe()
1255 fifo->rx.ctl = fifo->res0 + MLXBF_TMFIFO_RX_CTL; in mlxbf_tmfifo_probe()
1256 fifo->rx.sts = fifo->res0 + MLXBF_TMFIFO_RX_STS; in mlxbf_tmfifo_probe()
1257 fifo->rx.data = fifo->res0 + MLXBF_TMFIFO_RX_DATA; in mlxbf_tmfifo_probe()
1258 fifo->tx.ctl = fifo->res1 + MLXBF_TMFIFO_TX_CTL; in mlxbf_tmfifo_probe()
1259 fifo->tx.sts = fifo->res1 + MLXBF_TMFIFO_TX_STS; in mlxbf_tmfifo_probe()
1260 fifo->tx.data = fifo->res1 + MLXBF_TMFIFO_TX_DATA; in mlxbf_tmfifo_probe()
1263 platform_set_drvdata(pdev, fifo); in mlxbf_tmfifo_probe()
1265 timer_setup(&fifo->timer, mlxbf_tmfifo_timer, 0); in mlxbf_tmfifo_probe()
1268 fifo->irq_info[i].index = i; in mlxbf_tmfifo_probe()
1269 fifo->irq_info[i].fifo = fifo; in mlxbf_tmfifo_probe()
1270 fifo->irq_info[i].irq = platform_get_irq(pdev, i); in mlxbf_tmfifo_probe()
1271 rc = devm_request_irq(dev, fifo->irq_info[i].irq, in mlxbf_tmfifo_probe()
1273 "tmfifo", &fifo->irq_info[i]); in mlxbf_tmfifo_probe()
1276 fifo->irq_info[i].irq = 0; in mlxbf_tmfifo_probe()
1281 mlxbf_tmfifo_set_threshold(fifo); in mlxbf_tmfifo_probe()
1284 rc = mlxbf_tmfifo_create_vdev(dev, fifo, VIRTIO_ID_CONSOLE, 0, NULL, 0); in mlxbf_tmfifo_probe()
1297 rc = mlxbf_tmfifo_create_vdev(dev, fifo, VIRTIO_ID_NET, in mlxbf_tmfifo_probe()
1303 mod_timer(&fifo->timer, jiffies + MLXBF_TMFIFO_TIMER_INTERVAL); in mlxbf_tmfifo_probe()
1305 fifo->is_ready = true; in mlxbf_tmfifo_probe()
1309 mlxbf_tmfifo_cleanup(fifo); in mlxbf_tmfifo_probe()
1316 struct mlxbf_tmfifo *fifo = platform_get_drvdata(pdev); in mlxbf_tmfifo_remove() local
1318 mlxbf_tmfifo_cleanup(fifo); in mlxbf_tmfifo_remove()