Lines Matching refs:rx
196 struct lan743x_rx *rx = context; in lan743x_rx_isr() local
197 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_isr()
202 INT_BIT_DMA_RX_(rx->channel_number)); in lan743x_rx_isr()
205 if (int_sts & INT_BIT_DMA_RX_(rx->channel_number)) { in lan743x_rx_isr()
206 u32 rx_frame_bit = DMAC_INT_BIT_RXFRM_(rx->channel_number); in lan743x_rx_isr()
223 napi_schedule(&rx->napi); in lan743x_rx_isr()
231 INT_BIT_DMA_RX_(rx->channel_number)); in lan743x_rx_isr()
246 lan743x_rx_isr(&adapter->rx[channel], in lan743x_intr_shared_isr()
652 &adapter->rx[index]); in lan743x_intr_open()
1928 static int lan743x_rx_next_index(struct lan743x_rx *rx, int index) in lan743x_rx_next_index() argument
1930 return ((++index) % rx->ring_size); in lan743x_rx_next_index()
1933 static void lan743x_rx_update_tail(struct lan743x_rx *rx, int index) in lan743x_rx_update_tail() argument
1937 lan743x_csr_write(rx->adapter, RX_TAIL(rx->channel_number), in lan743x_rx_update_tail()
1941 static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index, in lan743x_rx_init_ring_element() argument
1944 struct net_device *netdev = rx->adapter->netdev; in lan743x_rx_init_ring_element()
1945 struct device *dev = &rx->adapter->pdev->dev; in lan743x_rx_init_ring_element()
1954 descriptor = &rx->ring_cpu_ptr[index]; in lan743x_rx_init_ring_element()
1955 buffer_info = &rx->buffer_info[index]; in lan743x_rx_init_ring_element()
1993 lan743x_rx_update_tail(rx, index); in lan743x_rx_init_ring_element()
1998 static void lan743x_rx_reuse_ring_element(struct lan743x_rx *rx, int index) in lan743x_rx_reuse_ring_element() argument
2003 descriptor = &rx->ring_cpu_ptr[index]; in lan743x_rx_reuse_ring_element()
2004 buffer_info = &rx->buffer_info[index]; in lan743x_rx_reuse_ring_element()
2012 lan743x_rx_update_tail(rx, index); in lan743x_rx_reuse_ring_element()
2015 static void lan743x_rx_release_ring_element(struct lan743x_rx *rx, int index) in lan743x_rx_release_ring_element() argument
2020 descriptor = &rx->ring_cpu_ptr[index]; in lan743x_rx_release_ring_element()
2021 buffer_info = &rx->buffer_info[index]; in lan743x_rx_release_ring_element()
2026 dma_unmap_single(&rx->adapter->pdev->dev, in lan743x_rx_release_ring_element()
2056 static int lan743x_rx_process_buffer(struct lan743x_rx *rx) in lan743x_rx_process_buffer() argument
2058 int current_head_index = le32_to_cpu(*rx->head_cpu_ptr); in lan743x_rx_process_buffer()
2060 struct net_device *netdev = rx->adapter->netdev; in lan743x_rx_process_buffer()
2068 if (current_head_index < 0 || current_head_index >= rx->ring_size) in lan743x_rx_process_buffer()
2071 if (rx->last_head < 0 || rx->last_head >= rx->ring_size) in lan743x_rx_process_buffer()
2074 if (rx->last_head == current_head_index) in lan743x_rx_process_buffer()
2077 descriptor = &rx->ring_cpu_ptr[rx->last_head]; in lan743x_rx_process_buffer()
2080 buffer_info = &rx->buffer_info[rx->last_head]; in lan743x_rx_process_buffer()
2087 int index = lan743x_rx_next_index(rx, rx->last_head); in lan743x_rx_process_buffer()
2092 desc_ext = &rx->ring_cpu_ptr[index]; in lan743x_rx_process_buffer()
2118 if (lan743x_rx_init_ring_element(rx, rx->last_head, in lan743x_rx_process_buffer()
2124 lan743x_rx_reuse_ring_element(rx, rx->last_head); in lan743x_rx_process_buffer()
2126 dev_kfree_skb_irq(rx->skb_head); in lan743x_rx_process_buffer()
2127 rx->skb_head = NULL; in lan743x_rx_process_buffer()
2135 if (rx->skb_head) in lan743x_rx_process_buffer()
2136 dev_kfree_skb_irq(rx->skb_head); in lan743x_rx_process_buffer()
2137 rx->skb_head = skb; in lan743x_rx_process_buffer()
2138 } else if (rx->skb_head) { in lan743x_rx_process_buffer()
2140 if (skb_shinfo(rx->skb_head)->frag_list) in lan743x_rx_process_buffer()
2141 rx->skb_tail->next = skb; in lan743x_rx_process_buffer()
2143 skb_shinfo(rx->skb_head)->frag_list = skb; in lan743x_rx_process_buffer()
2144 rx->skb_tail = skb; in lan743x_rx_process_buffer()
2145 rx->skb_head->len += skb->len; in lan743x_rx_process_buffer()
2146 rx->skb_head->data_len += skb->len; in lan743x_rx_process_buffer()
2147 rx->skb_head->truesize += skb->truesize; in lan743x_rx_process_buffer()
2164 if (rx->skb_head) in lan743x_rx_process_buffer()
2165 skb_hwtstamps(rx->skb_head)->hwtstamp = in lan743x_rx_process_buffer()
2167 lan743x_rx_reuse_ring_element(rx, extension_index); in lan743x_rx_process_buffer()
2168 rx->last_head = extension_index; in lan743x_rx_process_buffer()
2172 if (is_last && rx->skb_head) in lan743x_rx_process_buffer()
2173 rx->skb_head = lan743x_rx_trim_skb(rx->skb_head, frame_length); in lan743x_rx_process_buffer()
2175 if (is_last && rx->skb_head) { in lan743x_rx_process_buffer()
2176 rx->skb_head->protocol = eth_type_trans(rx->skb_head, in lan743x_rx_process_buffer()
2177 rx->adapter->netdev); in lan743x_rx_process_buffer()
2179 rx->skb_head->len); in lan743x_rx_process_buffer()
2180 napi_gro_receive(&rx->napi, rx->skb_head); in lan743x_rx_process_buffer()
2181 rx->skb_head = NULL; in lan743x_rx_process_buffer()
2186 rx->last_tail = rx->last_head; in lan743x_rx_process_buffer()
2187 rx->last_head = lan743x_rx_next_index(rx, rx->last_head); in lan743x_rx_process_buffer()
2195 struct lan743x_rx *rx = container_of(napi, struct lan743x_rx, napi); in lan743x_rx_napi_poll() local
2196 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_napi_poll()
2201 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_STATUS_W2C) { in lan743x_rx_napi_poll()
2204 DMAC_INT_BIT_RXFRM_(rx->channel_number)); in lan743x_rx_napi_poll()
2207 result = lan743x_rx_process_buffer(rx); in lan743x_rx_napi_poll()
2211 rx->frame_count += count; in lan743x_rx_napi_poll()
2219 if (rx->vector_flags & LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_SET) in lan743x_rx_napi_poll()
2221 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_SET) { in lan743x_rx_napi_poll()
2225 INT_BIT_DMA_RX_(rx->channel_number)); in lan743x_rx_napi_poll()
2229 lan743x_csr_write(adapter, RX_TAIL(rx->channel_number), in lan743x_rx_napi_poll()
2230 rx_tail_flags | rx->last_tail); in lan743x_rx_napi_poll()
2235 static void lan743x_rx_ring_cleanup(struct lan743x_rx *rx) in lan743x_rx_ring_cleanup() argument
2237 if (rx->buffer_info && rx->ring_cpu_ptr) { in lan743x_rx_ring_cleanup()
2240 for (index = 0; index < rx->ring_size; index++) in lan743x_rx_ring_cleanup()
2241 lan743x_rx_release_ring_element(rx, index); in lan743x_rx_ring_cleanup()
2244 if (rx->head_cpu_ptr) { in lan743x_rx_ring_cleanup()
2245 dma_free_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_cleanup()
2246 sizeof(*rx->head_cpu_ptr), rx->head_cpu_ptr, in lan743x_rx_ring_cleanup()
2247 rx->head_dma_ptr); in lan743x_rx_ring_cleanup()
2248 rx->head_cpu_ptr = NULL; in lan743x_rx_ring_cleanup()
2249 rx->head_dma_ptr = 0; in lan743x_rx_ring_cleanup()
2252 kfree(rx->buffer_info); in lan743x_rx_ring_cleanup()
2253 rx->buffer_info = NULL; in lan743x_rx_ring_cleanup()
2255 if (rx->ring_cpu_ptr) { in lan743x_rx_ring_cleanup()
2256 dma_free_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_cleanup()
2257 rx->ring_allocation_size, rx->ring_cpu_ptr, in lan743x_rx_ring_cleanup()
2258 rx->ring_dma_ptr); in lan743x_rx_ring_cleanup()
2259 rx->ring_allocation_size = 0; in lan743x_rx_ring_cleanup()
2260 rx->ring_cpu_ptr = NULL; in lan743x_rx_ring_cleanup()
2261 rx->ring_dma_ptr = 0; in lan743x_rx_ring_cleanup()
2264 rx->ring_size = 0; in lan743x_rx_ring_cleanup()
2265 rx->last_head = 0; in lan743x_rx_ring_cleanup()
2268 static int lan743x_rx_ring_init(struct lan743x_rx *rx) in lan743x_rx_ring_init() argument
2276 rx->ring_size = LAN743X_RX_RING_SIZE; in lan743x_rx_ring_init()
2277 if (rx->ring_size <= 1) { in lan743x_rx_ring_init()
2281 if (rx->ring_size & ~RX_CFG_B_RX_RING_LEN_MASK_) { in lan743x_rx_ring_init()
2285 if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2287 if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2289 dev_warn(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2295 ring_allocation_size = ALIGN(rx->ring_size * in lan743x_rx_ring_init()
2299 cpu_ptr = dma_alloc_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2305 rx->ring_allocation_size = ring_allocation_size; in lan743x_rx_ring_init()
2306 rx->ring_cpu_ptr = (struct lan743x_rx_descriptor *)cpu_ptr; in lan743x_rx_ring_init()
2307 rx->ring_dma_ptr = dma_ptr; in lan743x_rx_ring_init()
2309 cpu_ptr = kcalloc(rx->ring_size, sizeof(*rx->buffer_info), in lan743x_rx_ring_init()
2315 rx->buffer_info = (struct lan743x_rx_buffer_info *)cpu_ptr; in lan743x_rx_ring_init()
2317 cpu_ptr = dma_alloc_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2318 sizeof(*rx->head_cpu_ptr), &dma_ptr, in lan743x_rx_ring_init()
2325 rx->head_cpu_ptr = cpu_ptr; in lan743x_rx_ring_init()
2326 rx->head_dma_ptr = dma_ptr; in lan743x_rx_ring_init()
2327 if (rx->head_dma_ptr & 0x3) { in lan743x_rx_ring_init()
2332 rx->last_head = 0; in lan743x_rx_ring_init()
2333 for (index = 0; index < rx->ring_size; index++) { in lan743x_rx_ring_init()
2334 ret = lan743x_rx_init_ring_element(rx, index, GFP_KERNEL); in lan743x_rx_ring_init()
2341 netif_warn(rx->adapter, ifup, rx->adapter->netdev, in lan743x_rx_ring_init()
2344 lan743x_rx_ring_cleanup(rx); in lan743x_rx_ring_init()
2348 static void lan743x_rx_close(struct lan743x_rx *rx) in lan743x_rx_close() argument
2350 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_close()
2353 FCT_RX_CTL_DIS_(rx->channel_number)); in lan743x_rx_close()
2355 FCT_RX_CTL_EN_(rx->channel_number), in lan743x_rx_close()
2359 DMAC_CMD_STOP_R_(rx->channel_number)); in lan743x_rx_close()
2360 lan743x_dmac_rx_wait_till_stopped(adapter, rx->channel_number); in lan743x_rx_close()
2363 DMAC_INT_BIT_RXFRM_(rx->channel_number)); in lan743x_rx_close()
2365 INT_BIT_DMA_RX_(rx->channel_number)); in lan743x_rx_close()
2366 napi_disable(&rx->napi); in lan743x_rx_close()
2368 netif_napi_del(&rx->napi); in lan743x_rx_close()
2370 lan743x_rx_ring_cleanup(rx); in lan743x_rx_close()
2373 static int lan743x_rx_open(struct lan743x_rx *rx) in lan743x_rx_open() argument
2375 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_open()
2379 rx->frame_count = 0; in lan743x_rx_open()
2380 ret = lan743x_rx_ring_init(rx); in lan743x_rx_open()
2385 &rx->napi, lan743x_rx_napi_poll, in lan743x_rx_open()
2389 DMAC_CMD_RX_SWR_(rx->channel_number)); in lan743x_rx_open()
2391 DMAC_CMD_RX_SWR_(rx->channel_number), in lan743x_rx_open()
2396 RX_BASE_ADDRH(rx->channel_number), in lan743x_rx_open()
2397 DMA_ADDR_HIGH32(rx->ring_dma_ptr)); in lan743x_rx_open()
2399 RX_BASE_ADDRL(rx->channel_number), in lan743x_rx_open()
2400 DMA_ADDR_LOW32(rx->ring_dma_ptr)); in lan743x_rx_open()
2404 RX_HEAD_WRITEBACK_ADDRH(rx->channel_number), in lan743x_rx_open()
2405 DMA_ADDR_HIGH32(rx->head_dma_ptr)); in lan743x_rx_open()
2407 RX_HEAD_WRITEBACK_ADDRL(rx->channel_number), in lan743x_rx_open()
2408 DMA_ADDR_LOW32(rx->head_dma_ptr)); in lan743x_rx_open()
2419 RX_CFG_A(rx->channel_number), data); in lan743x_rx_open()
2422 data = lan743x_csr_read(adapter, RX_CFG_B(rx->channel_number)); in lan743x_rx_open()
2429 data |= ((rx->ring_size) & RX_CFG_B_RX_RING_LEN_MASK_); in lan743x_rx_open()
2434 lan743x_csr_write(adapter, RX_CFG_B(rx->channel_number), data); in lan743x_rx_open()
2435 rx->vector_flags = lan743x_intr_get_vector_flags(adapter, in lan743x_rx_open()
2437 (rx->channel_number)); in lan743x_rx_open()
2441 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_CLEAR) in lan743x_rx_open()
2443 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_STATUS_AUTO_CLEAR) in lan743x_rx_open()
2445 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_STATUS_R2C) in lan743x_rx_open()
2447 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_ENABLE_R2C) in lan743x_rx_open()
2449 lan743x_csr_write(adapter, RX_CFG_C(rx->channel_number), data); in lan743x_rx_open()
2451 rx->last_tail = ((u32)(rx->ring_size - 1)); in lan743x_rx_open()
2452 lan743x_csr_write(adapter, RX_TAIL(rx->channel_number), in lan743x_rx_open()
2453 rx->last_tail); in lan743x_rx_open()
2454 rx->last_head = lan743x_csr_read(adapter, RX_HEAD(rx->channel_number)); in lan743x_rx_open()
2455 if (rx->last_head) { in lan743x_rx_open()
2460 napi_enable(&rx->napi); in lan743x_rx_open()
2463 INT_BIT_DMA_RX_(rx->channel_number)); in lan743x_rx_open()
2465 DMAC_INT_BIT_RXFRM_(rx->channel_number)); in lan743x_rx_open()
2467 DMAC_INT_BIT_RXFRM_(rx->channel_number)); in lan743x_rx_open()
2469 DMAC_CMD_START_R_(rx->channel_number)); in lan743x_rx_open()
2473 FCT_RX_CTL_RESET_(rx->channel_number)); in lan743x_rx_open()
2475 FCT_RX_CTL_RESET_(rx->channel_number), in lan743x_rx_open()
2477 lan743x_csr_write(adapter, FCT_FLOW(rx->channel_number), in lan743x_rx_open()
2484 FCT_RX_CTL_EN_(rx->channel_number)); in lan743x_rx_open()
2488 netif_napi_del(&rx->napi); in lan743x_rx_open()
2489 lan743x_rx_ring_cleanup(rx); in lan743x_rx_open()
2503 lan743x_rx_close(&adapter->rx[index]); in lan743x_netdev_close()
2541 ret = lan743x_rx_open(&adapter->rx[index]); in lan743x_netdev_open()
2554 if (adapter->rx[index].ring_cpu_ptr) in lan743x_netdev_open()
2555 lan743x_rx_close(&adapter->rx[index]); in lan743x_netdev_open()
2736 adapter->rx[index].adapter = adapter; in lan743x_hardware_init()
2737 adapter->rx[index].channel_number = index; in lan743x_hardware_init()