Lines Matching refs:tx
218 struct lan743x_tx *tx = context; in lan743x_tx_isr() local
219 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_isr()
225 INT_BIT_DMA_TX_(tx->channel_number)); in lan743x_tx_isr()
228 if (int_sts & INT_BIT_DMA_TX_(tx->channel_number)) { in lan743x_tx_isr()
229 u32 ioc_bit = DMAC_INT_BIT_TX_IOC_(tx->channel_number); in lan743x_tx_isr()
246 napi_schedule(&tx->napi); in lan743x_tx_isr()
254 INT_BIT_DMA_TX_(tx->channel_number)); in lan743x_tx_isr()
321 lan743x_tx_isr(&adapter->tx[channel], in lan743x_intr_shared_isr()
679 &adapter->tx[index]); in lan743x_intr_open()
1749 static void lan743x_tx_release_desc(struct lan743x_tx *tx, in lan743x_tx_release_desc() argument
1757 descriptor = &tx->ring_cpu_ptr[descriptor_index]; in lan743x_tx_release_desc()
1758 buffer_info = &tx->buffer_info[descriptor_index]; in lan743x_tx_release_desc()
1773 dma_unmap_page(&tx->adapter->pdev->dev, in lan743x_tx_release_desc()
1778 dma_unmap_single(&tx->adapter->pdev->dev, in lan743x_tx_release_desc()
1795 lan743x_ptp_unrequest_tx_timestamp(tx->adapter); in lan743x_tx_release_desc()
1800 lan743x_ptp_tx_timestamp_skb(tx->adapter, in lan743x_tx_release_desc()
1815 static int lan743x_tx_next_index(struct lan743x_tx *tx, int index) in lan743x_tx_next_index() argument
1817 return ((++index) % tx->ring_size); in lan743x_tx_next_index()
1820 static void lan743x_tx_release_completed_descriptors(struct lan743x_tx *tx) in lan743x_tx_release_completed_descriptors() argument
1822 while (le32_to_cpu(*tx->head_cpu_ptr) != (tx->last_head)) { in lan743x_tx_release_completed_descriptors()
1823 lan743x_tx_release_desc(tx, tx->last_head, false); in lan743x_tx_release_completed_descriptors()
1824 tx->last_head = lan743x_tx_next_index(tx, tx->last_head); in lan743x_tx_release_completed_descriptors()
1828 static void lan743x_tx_release_all_descriptors(struct lan743x_tx *tx) in lan743x_tx_release_all_descriptors() argument
1832 original_head = tx->last_head; in lan743x_tx_release_all_descriptors()
1834 lan743x_tx_release_desc(tx, tx->last_head, true); in lan743x_tx_release_all_descriptors()
1835 tx->last_head = lan743x_tx_next_index(tx, tx->last_head); in lan743x_tx_release_all_descriptors()
1836 } while (tx->last_head != original_head); in lan743x_tx_release_all_descriptors()
1837 memset(tx->ring_cpu_ptr, 0, in lan743x_tx_release_all_descriptors()
1838 sizeof(*tx->ring_cpu_ptr) * (tx->ring_size)); in lan743x_tx_release_all_descriptors()
1839 memset(tx->buffer_info, 0, in lan743x_tx_release_all_descriptors()
1840 sizeof(*tx->buffer_info) * (tx->ring_size)); in lan743x_tx_release_all_descriptors()
1843 static int lan743x_tx_get_desc_cnt(struct lan743x_tx *tx, in lan743x_tx_get_desc_cnt() argument
1856 static int lan743x_tx_get_avail_desc(struct lan743x_tx *tx) in lan743x_tx_get_avail_desc() argument
1858 int last_head = tx->last_head; in lan743x_tx_get_avail_desc()
1859 int last_tail = tx->last_tail; in lan743x_tx_get_avail_desc()
1862 return tx->ring_size - last_tail + last_head - 1; in lan743x_tx_get_avail_desc()
1867 void lan743x_tx_set_timestamping_mode(struct lan743x_tx *tx, in lan743x_tx_set_timestamping_mode() argument
1872 tx->ts_flags |= TX_TS_FLAG_TIMESTAMPING_ENABLED; in lan743x_tx_set_timestamping_mode()
1874 tx->ts_flags &= ~TX_TS_FLAG_TIMESTAMPING_ENABLED; in lan743x_tx_set_timestamping_mode()
1876 tx->ts_flags |= TX_TS_FLAG_ONE_STEP_SYNC; in lan743x_tx_set_timestamping_mode()
1878 tx->ts_flags &= ~TX_TS_FLAG_ONE_STEP_SYNC; in lan743x_tx_set_timestamping_mode()
1881 static int lan743x_tx_frame_start(struct lan743x_tx *tx, in lan743x_tx_frame_start() argument
1893 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_frame_start()
1897 tx->frame_flags |= TX_FRAME_FLAG_IN_PROGRESS; in lan743x_tx_frame_start()
1898 tx->frame_first = tx->last_tail; in lan743x_tx_frame_start()
1899 tx->frame_tail = tx->frame_first; in lan743x_tx_frame_start()
1901 tx_descriptor = &tx->ring_cpu_ptr[tx->frame_tail]; in lan743x_tx_frame_start()
1902 buffer_info = &tx->buffer_info[tx->frame_tail]; in lan743x_tx_frame_start()
1918 tx->frame_data0 = (first_buffer_length & in lan743x_tx_frame_start()
1924 tx->frame_data0 |= TX_DESC_DATA0_TSE_; in lan743x_tx_frame_start()
1927 tx->frame_data0 |= TX_DESC_DATA0_ICE_ | in lan743x_tx_frame_start()
1935 static void lan743x_tx_frame_add_lso(struct lan743x_tx *tx, in lan743x_tx_frame_add_lso() argument
1946 tx->frame_data0 |= TX_DESC_DATA0_EXT_; in lan743x_tx_frame_add_lso()
1948 tx->frame_data0 |= TX_DESC_DATA0_LS_; in lan743x_tx_frame_add_lso()
1949 tx->frame_data0 |= TX_DESC_DATA0_IOC_; in lan743x_tx_frame_add_lso()
1951 tx_descriptor = &tx->ring_cpu_ptr[tx->frame_tail]; in lan743x_tx_frame_add_lso()
1952 tx_descriptor->data0 = cpu_to_le32(tx->frame_data0); in lan743x_tx_frame_add_lso()
1955 tx->frame_tail = lan743x_tx_next_index(tx, tx->frame_tail); in lan743x_tx_frame_add_lso()
1956 tx_descriptor = &tx->ring_cpu_ptr[tx->frame_tail]; in lan743x_tx_frame_add_lso()
1957 buffer_info = &tx->buffer_info[tx->frame_tail]; in lan743x_tx_frame_add_lso()
1969 tx->frame_data0 = (frame_length & TX_DESC_DATA0_EXT_PAY_LENGTH_MASK_) | in lan743x_tx_frame_add_lso()
1976 static int lan743x_tx_frame_add_fragment(struct lan743x_tx *tx, in lan743x_tx_frame_add_fragment() argument
1985 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_frame_add_fragment()
1995 tx_descriptor = &tx->ring_cpu_ptr[tx->frame_tail]; in lan743x_tx_frame_add_fragment()
1996 tx_descriptor->data0 = cpu_to_le32(tx->frame_data0); in lan743x_tx_frame_add_fragment()
1999 tx->frame_tail = lan743x_tx_next_index(tx, tx->frame_tail); in lan743x_tx_frame_add_fragment()
2000 tx_descriptor = &tx->ring_cpu_ptr[tx->frame_tail]; in lan743x_tx_frame_add_fragment()
2001 buffer_info = &tx->buffer_info[tx->frame_tail]; in lan743x_tx_frame_add_fragment()
2009 desc_index = tx->frame_first; in lan743x_tx_frame_add_fragment()
2010 while (desc_index != tx->frame_tail) { in lan743x_tx_frame_add_fragment()
2011 lan743x_tx_release_desc(tx, desc_index, true); in lan743x_tx_frame_add_fragment()
2012 desc_index = lan743x_tx_next_index(tx, desc_index); in lan743x_tx_frame_add_fragment()
2015 tx->frame_flags &= ~TX_FRAME_FLAG_IN_PROGRESS; in lan743x_tx_frame_add_fragment()
2016 tx->frame_first = 0; in lan743x_tx_frame_add_fragment()
2017 tx->frame_data0 = 0; in lan743x_tx_frame_add_fragment()
2018 tx->frame_tail = 0; in lan743x_tx_frame_add_fragment()
2033 tx->frame_data0 = (fragment_length & TX_DESC_DATA0_BUF_LENGTH_MASK_) | in lan743x_tx_frame_add_fragment()
2041 static void lan743x_tx_frame_end(struct lan743x_tx *tx, in lan743x_tx_frame_end() argument
2051 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_frame_end()
2055 if ((tx->frame_data0 & TX_DESC_DATA0_DTYPE_MASK_) == in lan743x_tx_frame_end()
2057 tx->frame_data0 |= TX_DESC_DATA0_LS_; in lan743x_tx_frame_end()
2058 tx->frame_data0 |= TX_DESC_DATA0_IOC_; in lan743x_tx_frame_end()
2061 tx_descriptor = &tx->ring_cpu_ptr[tx->frame_tail]; in lan743x_tx_frame_end()
2062 buffer_info = &tx->buffer_info[tx->frame_tail]; in lan743x_tx_frame_end()
2069 tx_descriptor->data0 = cpu_to_le32(tx->frame_data0); in lan743x_tx_frame_end()
2070 tx->frame_tail = lan743x_tx_next_index(tx, tx->frame_tail); in lan743x_tx_frame_end()
2071 tx->last_tail = tx->frame_tail; in lan743x_tx_frame_end()
2075 if (tx->vector_flags & LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_SET) in lan743x_tx_frame_end()
2077 if (tx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_SET) in lan743x_tx_frame_end()
2081 lan743x_csr_write(adapter, TX_TAIL(tx->channel_number), in lan743x_tx_frame_end()
2082 tx_tail_flags | tx->frame_tail); in lan743x_tx_frame_end()
2083 tx->frame_flags &= ~TX_FRAME_FLAG_IN_PROGRESS; in lan743x_tx_frame_end()
2086 static netdev_tx_t lan743x_tx_xmit_frame(struct lan743x_tx *tx, in lan743x_tx_xmit_frame() argument
2102 required_number_of_descriptors = lan743x_tx_get_desc_cnt(tx, skb); in lan743x_tx_xmit_frame()
2104 spin_lock_irqsave(&tx->ring_lock, irq_flags); in lan743x_tx_xmit_frame()
2106 lan743x_tx_get_avail_desc(tx)) { in lan743x_tx_xmit_frame()
2107 if (required_number_of_descriptors > (tx->ring_size - 1)) { in lan743x_tx_xmit_frame()
2111 tx->rqd_descriptors = required_number_of_descriptors; in lan743x_tx_xmit_frame()
2113 txq = netdev_get_tx_queue(tx->adapter->netdev, in lan743x_tx_xmit_frame()
2114 tx->channel_number); in lan743x_tx_xmit_frame()
2122 (tx->ts_flags & TX_TS_FLAG_TIMESTAMPING_ENABLED) && in lan743x_tx_xmit_frame()
2123 (lan743x_ptp_request_tx_timestamp(tx->adapter))) { in lan743x_tx_xmit_frame()
2126 if (tx->ts_flags & TX_TS_FLAG_ONE_STEP_SYNC) in lan743x_tx_xmit_frame()
2139 if (lan743x_tx_frame_start(tx, in lan743x_tx_xmit_frame()
2147 tx->frame_count++; in lan743x_tx_xmit_frame()
2150 lan743x_tx_frame_add_lso(tx, frame_length, nr_frags); in lan743x_tx_xmit_frame()
2158 if (lan743x_tx_frame_add_fragment(tx, frag, frame_length)) { in lan743x_tx_xmit_frame()
2170 lan743x_tx_frame_end(tx, skb, do_timestamp, ignore_sync); in lan743x_tx_xmit_frame()
2173 spin_unlock_irqrestore(&tx->ring_lock, irq_flags); in lan743x_tx_xmit_frame()
2179 struct lan743x_tx *tx = container_of(napi, struct lan743x_tx, napi); in lan743x_tx_napi_poll() local
2180 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_napi_poll()
2185 ioc_bit = DMAC_INT_BIT_TX_IOC_(tx->channel_number); in lan743x_tx_napi_poll()
2187 if (tx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_STATUS_W2C) in lan743x_tx_napi_poll()
2189 spin_lock_irqsave(&tx->ring_lock, irq_flags); in lan743x_tx_napi_poll()
2192 lan743x_tx_release_completed_descriptors(tx); in lan743x_tx_napi_poll()
2193 txq = netdev_get_tx_queue(adapter->netdev, tx->channel_number); in lan743x_tx_napi_poll()
2195 if (tx->rqd_descriptors) { in lan743x_tx_napi_poll()
2196 if (tx->rqd_descriptors <= in lan743x_tx_napi_poll()
2197 lan743x_tx_get_avail_desc(tx)) { in lan743x_tx_napi_poll()
2198 tx->rqd_descriptors = 0; in lan743x_tx_napi_poll()
2205 spin_unlock_irqrestore(&tx->ring_lock, irq_flags); in lan743x_tx_napi_poll()
2212 INT_BIT_DMA_TX_(tx->channel_number)); in lan743x_tx_napi_poll()
2219 static void lan743x_tx_ring_cleanup(struct lan743x_tx *tx) in lan743x_tx_ring_cleanup() argument
2221 if (tx->head_cpu_ptr) { in lan743x_tx_ring_cleanup()
2222 dma_free_coherent(&tx->adapter->pdev->dev, in lan743x_tx_ring_cleanup()
2223 sizeof(*tx->head_cpu_ptr), tx->head_cpu_ptr, in lan743x_tx_ring_cleanup()
2224 tx->head_dma_ptr); in lan743x_tx_ring_cleanup()
2225 tx->head_cpu_ptr = NULL; in lan743x_tx_ring_cleanup()
2226 tx->head_dma_ptr = 0; in lan743x_tx_ring_cleanup()
2228 kfree(tx->buffer_info); in lan743x_tx_ring_cleanup()
2229 tx->buffer_info = NULL; in lan743x_tx_ring_cleanup()
2231 if (tx->ring_cpu_ptr) { in lan743x_tx_ring_cleanup()
2232 dma_free_coherent(&tx->adapter->pdev->dev, in lan743x_tx_ring_cleanup()
2233 tx->ring_allocation_size, tx->ring_cpu_ptr, in lan743x_tx_ring_cleanup()
2234 tx->ring_dma_ptr); in lan743x_tx_ring_cleanup()
2235 tx->ring_allocation_size = 0; in lan743x_tx_ring_cleanup()
2236 tx->ring_cpu_ptr = NULL; in lan743x_tx_ring_cleanup()
2237 tx->ring_dma_ptr = 0; in lan743x_tx_ring_cleanup()
2239 tx->ring_size = 0; in lan743x_tx_ring_cleanup()
2242 static int lan743x_tx_ring_init(struct lan743x_tx *tx) in lan743x_tx_ring_init() argument
2249 tx->ring_size = LAN743X_TX_RING_SIZE; in lan743x_tx_ring_init()
2250 if (tx->ring_size & ~TX_CFG_B_TX_RING_LEN_MASK_) { in lan743x_tx_ring_init()
2254 if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev, in lan743x_tx_ring_init()
2256 dev_warn(&tx->adapter->pdev->dev, in lan743x_tx_ring_init()
2261 ring_allocation_size = ALIGN(tx->ring_size * in lan743x_tx_ring_init()
2265 cpu_ptr = dma_alloc_coherent(&tx->adapter->pdev->dev, in lan743x_tx_ring_init()
2272 tx->ring_allocation_size = ring_allocation_size; in lan743x_tx_ring_init()
2273 tx->ring_cpu_ptr = (struct lan743x_tx_descriptor *)cpu_ptr; in lan743x_tx_ring_init()
2274 tx->ring_dma_ptr = dma_ptr; in lan743x_tx_ring_init()
2276 cpu_ptr = kcalloc(tx->ring_size, sizeof(*tx->buffer_info), GFP_KERNEL); in lan743x_tx_ring_init()
2281 tx->buffer_info = (struct lan743x_tx_buffer_info *)cpu_ptr; in lan743x_tx_ring_init()
2283 cpu_ptr = dma_alloc_coherent(&tx->adapter->pdev->dev, in lan743x_tx_ring_init()
2284 sizeof(*tx->head_cpu_ptr), &dma_ptr, in lan743x_tx_ring_init()
2291 tx->head_cpu_ptr = cpu_ptr; in lan743x_tx_ring_init()
2292 tx->head_dma_ptr = dma_ptr; in lan743x_tx_ring_init()
2293 if (tx->head_dma_ptr & 0x3) { in lan743x_tx_ring_init()
2301 lan743x_tx_ring_cleanup(tx); in lan743x_tx_ring_init()
2305 static void lan743x_tx_close(struct lan743x_tx *tx) in lan743x_tx_close() argument
2307 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_close()
2311 DMAC_CMD_STOP_T_(tx->channel_number)); in lan743x_tx_close()
2312 lan743x_dmac_tx_wait_till_stopped(adapter, tx->channel_number); in lan743x_tx_close()
2316 DMAC_INT_BIT_TX_IOC_(tx->channel_number)); in lan743x_tx_close()
2318 INT_BIT_DMA_TX_(tx->channel_number)); in lan743x_tx_close()
2319 napi_disable(&tx->napi); in lan743x_tx_close()
2320 netif_napi_del(&tx->napi); in lan743x_tx_close()
2323 FCT_TX_CTL_DIS_(tx->channel_number)); in lan743x_tx_close()
2325 FCT_TX_CTL_EN_(tx->channel_number), in lan743x_tx_close()
2328 lan743x_tx_release_all_descriptors(tx); in lan743x_tx_close()
2330 tx->rqd_descriptors = 0; in lan743x_tx_close()
2332 lan743x_tx_ring_cleanup(tx); in lan743x_tx_close()
2335 static int lan743x_tx_open(struct lan743x_tx *tx) in lan743x_tx_open() argument
2341 adapter = tx->adapter; in lan743x_tx_open()
2342 ret = lan743x_tx_ring_init(tx); in lan743x_tx_open()
2348 FCT_TX_CTL_RESET_(tx->channel_number)); in lan743x_tx_open()
2350 FCT_TX_CTL_RESET_(tx->channel_number), in lan743x_tx_open()
2355 FCT_TX_CTL_EN_(tx->channel_number)); in lan743x_tx_open()
2359 DMAC_CMD_TX_SWR_(tx->channel_number)); in lan743x_tx_open()
2361 DMAC_CMD_TX_SWR_(tx->channel_number), in lan743x_tx_open()
2366 TX_BASE_ADDRH(tx->channel_number), in lan743x_tx_open()
2367 DMA_ADDR_HIGH32(tx->ring_dma_ptr)); in lan743x_tx_open()
2369 TX_BASE_ADDRL(tx->channel_number), in lan743x_tx_open()
2370 DMA_ADDR_LOW32(tx->ring_dma_ptr)); in lan743x_tx_open()
2373 data = lan743x_csr_read(adapter, TX_CFG_B(tx->channel_number)); in lan743x_tx_open()
2375 data |= ((tx->ring_size) & TX_CFG_B_TX_RING_LEN_MASK_); in lan743x_tx_open()
2378 lan743x_csr_write(adapter, TX_CFG_B(tx->channel_number), data); in lan743x_tx_open()
2388 lan743x_csr_write(adapter, TX_CFG_A(tx->channel_number), data); in lan743x_tx_open()
2392 TX_HEAD_WRITEBACK_ADDRH(tx->channel_number), in lan743x_tx_open()
2393 DMA_ADDR_HIGH32(tx->head_dma_ptr)); in lan743x_tx_open()
2395 TX_HEAD_WRITEBACK_ADDRL(tx->channel_number), in lan743x_tx_open()
2396 DMA_ADDR_LOW32(tx->head_dma_ptr)); in lan743x_tx_open()
2399 tx->last_head = lan743x_csr_read(adapter, TX_HEAD(tx->channel_number)); in lan743x_tx_open()
2402 tx->last_tail = 0; in lan743x_tx_open()
2403 lan743x_csr_write(adapter, TX_TAIL(tx->channel_number), in lan743x_tx_open()
2404 (u32)(tx->last_tail)); in lan743x_tx_open()
2405 tx->vector_flags = lan743x_intr_get_vector_flags(adapter, in lan743x_tx_open()
2407 (tx->channel_number)); in lan743x_tx_open()
2409 &tx->napi, lan743x_tx_napi_poll, in lan743x_tx_open()
2411 napi_enable(&tx->napi); in lan743x_tx_open()
2414 if (tx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_CLEAR) in lan743x_tx_open()
2416 if (tx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_STATUS_AUTO_CLEAR) in lan743x_tx_open()
2418 if (tx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_STATUS_R2C) in lan743x_tx_open()
2420 if (tx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_ENABLE_R2C) in lan743x_tx_open()
2422 lan743x_csr_write(adapter, TX_CFG_C(tx->channel_number), data); in lan743x_tx_open()
2424 if (!(tx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_SET)) in lan743x_tx_open()
2426 INT_BIT_DMA_TX_(tx->channel_number)); in lan743x_tx_open()
2428 DMAC_INT_BIT_TX_IOC_(tx->channel_number)); in lan743x_tx_open()
2432 DMAC_CMD_START_T_(tx->channel_number)); in lan743x_tx_open()
3012 lan743x_tx_close(&adapter->tx[index]); in lan743x_netdev_close()
3059 ret = lan743x_tx_open(&adapter->tx[index]); in lan743x_netdev_open()
3067 if (adapter->tx[index].ring_cpu_ptr) in lan743x_netdev_open()
3068 lan743x_tx_close(&adapter->tx[index]); in lan743x_netdev_open()
3102 return lan743x_tx_xmit_frame(&adapter->tx[ch], skb); in lan743x_netdev_xmit_frame()
3229 struct lan743x_tx *tx; in lan743x_hardware_init() local
3278 tx = &adapter->tx[index]; in lan743x_hardware_init()
3279 tx->adapter = adapter; in lan743x_hardware_init()
3280 tx->channel_number = index; in lan743x_hardware_init()
3281 spin_lock_init(&tx->ring_lock); in lan743x_hardware_init()