Lines Matching +full:recv +full:- +full:not +full:- +full:empty
1 // SPDX-License-Identifier: GPL-2.0-only
56 priv->txctrlreg = SGDMA_CTRLREG_ILASTD | in sgdma_initialize()
59 priv->rxctrlreg = SGDMA_CTRLREG_IDESCRIP | in sgdma_initialize()
63 INIT_LIST_HEAD(&priv->txlisthd); in sgdma_initialize()
64 INIT_LIST_HEAD(&priv->rxlisthd); in sgdma_initialize()
66 priv->rxdescphys = (dma_addr_t) 0; in sgdma_initialize()
67 priv->txdescphys = (dma_addr_t) 0; in sgdma_initialize()
69 priv->rxdescphys = dma_map_single(priv->device, in sgdma_initialize()
70 (void __force *)priv->rx_dma_desc, in sgdma_initialize()
71 priv->rxdescmem, DMA_BIDIRECTIONAL); in sgdma_initialize()
73 if (dma_mapping_error(priv->device, priv->rxdescphys)) { in sgdma_initialize()
75 netdev_err(priv->dev, "error mapping rx descriptor memory\n"); in sgdma_initialize()
76 return -EINVAL; in sgdma_initialize()
79 priv->txdescphys = dma_map_single(priv->device, in sgdma_initialize()
80 (void __force *)priv->tx_dma_desc, in sgdma_initialize()
81 priv->txdescmem, DMA_TO_DEVICE); in sgdma_initialize()
83 if (dma_mapping_error(priv->device, priv->txdescphys)) { in sgdma_initialize()
85 netdev_err(priv->dev, "error mapping tx descriptor memory\n"); in sgdma_initialize()
86 return -EINVAL; in sgdma_initialize()
90 memset_io(priv->tx_dma_desc, 0, priv->txdescmem); in sgdma_initialize()
91 memset_io(priv->rx_dma_desc, 0, priv->rxdescmem); in sgdma_initialize()
93 dma_sync_single_for_device(priv->device, priv->txdescphys, in sgdma_initialize()
94 priv->txdescmem, DMA_TO_DEVICE); in sgdma_initialize()
96 dma_sync_single_for_device(priv->device, priv->rxdescphys, in sgdma_initialize()
97 priv->rxdescmem, DMA_TO_DEVICE); in sgdma_initialize()
104 if (priv->rxdescphys) in sgdma_uninitialize()
105 dma_unmap_single(priv->device, priv->rxdescphys, in sgdma_uninitialize()
106 priv->rxdescmem, DMA_BIDIRECTIONAL); in sgdma_uninitialize()
108 if (priv->txdescphys) in sgdma_uninitialize()
109 dma_unmap_single(priv->device, priv->txdescphys, in sgdma_uninitialize()
110 priv->txdescmem, DMA_TO_DEVICE); in sgdma_uninitialize()
119 memset_io(priv->tx_dma_desc, 0, priv->txdescmem); in sgdma_reset()
120 memset_io(priv->rx_dma_desc, 0, priv->rxdescmem); in sgdma_reset()
122 csrwr32(SGDMA_CTRLREG_RESET, priv->tx_dma_csr, sgdma_csroffs(control)); in sgdma_reset()
123 csrwr32(0, priv->tx_dma_csr, sgdma_csroffs(control)); in sgdma_reset()
125 csrwr32(SGDMA_CTRLREG_RESET, priv->rx_dma_csr, sgdma_csroffs(control)); in sgdma_reset()
126 csrwr32(0, priv->rx_dma_csr, sgdma_csroffs(control)); in sgdma_reset()
152 tse_set_bit(priv->rx_dma_csr, sgdma_csroffs(control), in sgdma_clear_rxirq()
158 tse_set_bit(priv->tx_dma_csr, sgdma_csroffs(control), in sgdma_clear_txirq()
163 * transmitted, 0 if not possible.
170 (struct sgdma_descrip __iomem *)priv->tx_dma_desc; in sgdma_tx_buffer()
182 buffer->dma_addr, /* address of packet to xmit */ in sgdma_tx_buffer()
184 buffer->len, /* length of packet */ in sgdma_tx_buffer()
205 ((csrrd8(priv->tx_dma_desc, sgdma_descroffs(control)) in sgdma_tx_completions()
231 (struct sgdma_descrip __iomem *)priv->rx_dma_desc; in sgdma_rx_status()
236 u32 sts = csrrd32(priv->rx_dma_csr, sgdma_csroffs(status)); in sgdma_rx_status()
242 dma_sync_single_for_cpu(priv->device, in sgdma_rx_status()
243 priv->rxdescphys, in sgdma_rx_status()
258 netdev_info(priv->dev, in sgdma_rx_status()
259 "sgdma rx and rx queue empty!\n"); in sgdma_rx_status()
262 csrwr32(0, priv->rx_dma_csr, sgdma_csroffs(control)); in sgdma_rx_status()
264 csrwr32(0xf, priv->rx_dma_csr, sgdma_csroffs(status)); in sgdma_rx_status()
270 /* If the SGDMA indicated an end of packet on recv, in sgdma_rx_status()
272 * descriptor is non-zero - meaning a valid packet in sgdma_rx_status()
274 * indicated. if not, then all we can do is signal in sgdma_rx_status()
279 netdev_err(priv->dev, in sgdma_rx_status()
303 /* Clear the next descriptor as not owned by hardware */ in sgdma_setup_descrip()
331 * if status register is 0 - meaning initial state, restart async read,
333 * If read status indicate not busy and a status, restart the async
339 (struct sgdma_descrip __iomem *)priv->rx_dma_desc; in sgdma_async_read()
348 netdev_err(priv->dev, "no rx buffers available\n"); in sgdma_async_read()
356 rxbuffer->dma_addr, /* write addr for rx dma */ in sgdma_async_read()
362 dma_sync_single_for_device(priv->device, in sgdma_async_read()
363 priv->rxdescphys, in sgdma_async_read()
368 priv->rx_dma_csr, in sgdma_async_read()
371 csrwr32((priv->rxctrlreg | SGDMA_CTRLREG_START), in sgdma_async_read()
372 priv->rx_dma_csr, in sgdma_async_read()
388 csrwr32(0, priv->tx_dma_csr, sgdma_csroffs(control)); in sgdma_async_write()
389 csrwr32(0x1f, priv->tx_dma_csr, sgdma_csroffs(status)); in sgdma_async_write()
391 dma_sync_single_for_device(priv->device, priv->txdescphys, in sgdma_async_write()
395 priv->tx_dma_csr, in sgdma_async_write()
398 csrwr32((priv->txctrlreg | SGDMA_CTRLREG_START), in sgdma_async_write()
399 priv->tx_dma_csr, in sgdma_async_write()
409 dma_addr_t paddr = priv->txdescmem_busaddr; in sgdma_txphysaddr()
410 uintptr_t offs = (uintptr_t)desc - (uintptr_t)priv->tx_dma_desc; in sgdma_txphysaddr()
418 dma_addr_t paddr = priv->rxdescmem_busaddr; in sgdma_rxphysaddr()
419 uintptr_t offs = (uintptr_t)desc - (uintptr_t)priv->rx_dma_desc; in sgdma_rxphysaddr()
427 entry = list_entry((list)->next, type, member); \
428 list_del_init(&entry->member); \
436 entry = list_entry((list)->next, type, member); \
447 list_add_tail(&buffer->lh, &priv->txlisthd); in queue_tx()
458 list_add_tail(&buffer->lh, &priv->rxlisthd); in queue_rx()
462 * returns NULL if empty.
470 list_remove_head(&priv->txlisthd, buffer, struct tse_buffer, lh); in dequeue_tx()
475 * returns NULL if empty
483 list_remove_head(&priv->rxlisthd, buffer, struct tse_buffer, lh); in dequeue_rx()
488 * returns NULL if empty
497 list_peek_head(&priv->rxlisthd, buffer, struct tse_buffer, lh); in queue_rx_peekhead()
505 return csrrd32(priv->rx_dma_csr, sgdma_csroffs(status)) in sgdma_rxbusy()
517 while ((csrrd32(priv->tx_dma_csr, sgdma_csroffs(status)) in sgdma_txbusy()
521 if (csrrd32(priv->tx_dma_csr, sgdma_csroffs(status)) in sgdma_txbusy()
523 netdev_err(priv->dev, "timeout waiting for tx dma\n"); in sgdma_txbusy()