Lines Matching refs:rx
261 struct lan743x_rx *rx = context; in lan743x_rx_isr() local
262 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_isr()
267 INT_BIT_DMA_RX_(rx->channel_number)); in lan743x_rx_isr()
270 if (int_sts & INT_BIT_DMA_RX_(rx->channel_number)) { in lan743x_rx_isr()
271 u32 rx_frame_bit = DMAC_INT_BIT_RXFRM_(rx->channel_number); in lan743x_rx_isr()
288 napi_schedule(&rx->napi); in lan743x_rx_isr()
296 INT_BIT_DMA_RX_(rx->channel_number)); in lan743x_rx_isr()
311 lan743x_rx_isr(&adapter->rx[channel], in lan743x_intr_shared_isr()
731 &adapter->rx[index]); in lan743x_intr_open()
2438 static int lan743x_rx_next_index(struct lan743x_rx *rx, int index) in lan743x_rx_next_index() argument
2440 return ((++index) % rx->ring_size); in lan743x_rx_next_index()
2443 static void lan743x_rx_update_tail(struct lan743x_rx *rx, int index) in lan743x_rx_update_tail() argument
2447 lan743x_csr_write(rx->adapter, RX_TAIL(rx->channel_number), in lan743x_rx_update_tail()
2451 static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index, in lan743x_rx_init_ring_element() argument
2454 struct net_device *netdev = rx->adapter->netdev; in lan743x_rx_init_ring_element()
2455 struct device *dev = &rx->adapter->pdev->dev; in lan743x_rx_init_ring_element()
2464 descriptor = &rx->ring_cpu_ptr[index]; in lan743x_rx_init_ring_element()
2465 buffer_info = &rx->buffer_info[index]; in lan743x_rx_init_ring_element()
2503 lan743x_rx_update_tail(rx, index); in lan743x_rx_init_ring_element()
2508 static void lan743x_rx_reuse_ring_element(struct lan743x_rx *rx, int index) in lan743x_rx_reuse_ring_element() argument
2513 descriptor = &rx->ring_cpu_ptr[index]; in lan743x_rx_reuse_ring_element()
2514 buffer_info = &rx->buffer_info[index]; in lan743x_rx_reuse_ring_element()
2522 lan743x_rx_update_tail(rx, index); in lan743x_rx_reuse_ring_element()
2525 static void lan743x_rx_release_ring_element(struct lan743x_rx *rx, int index) in lan743x_rx_release_ring_element() argument
2530 descriptor = &rx->ring_cpu_ptr[index]; in lan743x_rx_release_ring_element()
2531 buffer_info = &rx->buffer_info[index]; in lan743x_rx_release_ring_element()
2536 dma_unmap_single(&rx->adapter->pdev->dev, in lan743x_rx_release_ring_element()
2566 static int lan743x_rx_process_buffer(struct lan743x_rx *rx) in lan743x_rx_process_buffer() argument
2568 int current_head_index = le32_to_cpu(*rx->head_cpu_ptr); in lan743x_rx_process_buffer()
2570 struct net_device *netdev = rx->adapter->netdev; in lan743x_rx_process_buffer()
2579 if (current_head_index < 0 || current_head_index >= rx->ring_size) in lan743x_rx_process_buffer()
2582 if (rx->last_head < 0 || rx->last_head >= rx->ring_size) in lan743x_rx_process_buffer()
2585 if (rx->last_head == current_head_index) in lan743x_rx_process_buffer()
2588 descriptor = &rx->ring_cpu_ptr[rx->last_head]; in lan743x_rx_process_buffer()
2591 buffer_info = &rx->buffer_info[rx->last_head]; in lan743x_rx_process_buffer()
2598 int index = lan743x_rx_next_index(rx, rx->last_head); in lan743x_rx_process_buffer()
2603 desc_ext = &rx->ring_cpu_ptr[index]; in lan743x_rx_process_buffer()
2632 if (lan743x_rx_init_ring_element(rx, rx->last_head, in lan743x_rx_process_buffer()
2638 lan743x_rx_reuse_ring_element(rx, rx->last_head); in lan743x_rx_process_buffer()
2640 dev_kfree_skb_irq(rx->skb_head); in lan743x_rx_process_buffer()
2641 rx->skb_head = NULL; in lan743x_rx_process_buffer()
2649 if (rx->skb_head) in lan743x_rx_process_buffer()
2650 dev_kfree_skb_irq(rx->skb_head); in lan743x_rx_process_buffer()
2651 rx->skb_head = skb; in lan743x_rx_process_buffer()
2652 } else if (rx->skb_head) { in lan743x_rx_process_buffer()
2654 if (skb_shinfo(rx->skb_head)->frag_list) in lan743x_rx_process_buffer()
2655 rx->skb_tail->next = skb; in lan743x_rx_process_buffer()
2657 skb_shinfo(rx->skb_head)->frag_list = skb; in lan743x_rx_process_buffer()
2658 rx->skb_tail = skb; in lan743x_rx_process_buffer()
2659 rx->skb_head->len += skb->len; in lan743x_rx_process_buffer()
2660 rx->skb_head->data_len += skb->len; in lan743x_rx_process_buffer()
2661 rx->skb_head->truesize += skb->truesize; in lan743x_rx_process_buffer()
2678 if (rx->skb_head) in lan743x_rx_process_buffer()
2679 skb_hwtstamps(rx->skb_head)->hwtstamp = in lan743x_rx_process_buffer()
2681 lan743x_rx_reuse_ring_element(rx, extension_index); in lan743x_rx_process_buffer()
2682 rx->last_head = extension_index; in lan743x_rx_process_buffer()
2686 if (is_last && rx->skb_head) in lan743x_rx_process_buffer()
2687 rx->skb_head = lan743x_rx_trim_skb(rx->skb_head, frame_length); in lan743x_rx_process_buffer()
2689 if (is_last && rx->skb_head) { in lan743x_rx_process_buffer()
2690 rx->skb_head->protocol = eth_type_trans(rx->skb_head, in lan743x_rx_process_buffer()
2691 rx->adapter->netdev); in lan743x_rx_process_buffer()
2692 if (rx->adapter->netdev->features & NETIF_F_RXCSUM) { in lan743x_rx_process_buffer()
2697 rx->skb_head->len); in lan743x_rx_process_buffer()
2698 napi_gro_receive(&rx->napi, rx->skb_head); in lan743x_rx_process_buffer()
2699 rx->skb_head = NULL; in lan743x_rx_process_buffer()
2704 rx->last_tail = rx->last_head; in lan743x_rx_process_buffer()
2705 rx->last_head = lan743x_rx_next_index(rx, rx->last_head); in lan743x_rx_process_buffer()
2713 struct lan743x_rx *rx = container_of(napi, struct lan743x_rx, napi); in lan743x_rx_napi_poll() local
2714 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_napi_poll()
2719 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_STATUS_W2C) { in lan743x_rx_napi_poll()
2722 DMAC_INT_BIT_RXFRM_(rx->channel_number)); in lan743x_rx_napi_poll()
2725 result = lan743x_rx_process_buffer(rx); in lan743x_rx_napi_poll()
2729 rx->frame_count += count; in lan743x_rx_napi_poll()
2737 if (rx->vector_flags & LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_SET) in lan743x_rx_napi_poll()
2739 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_SET) { in lan743x_rx_napi_poll()
2743 INT_BIT_DMA_RX_(rx->channel_number)); in lan743x_rx_napi_poll()
2747 lan743x_csr_write(adapter, RX_TAIL(rx->channel_number), in lan743x_rx_napi_poll()
2748 rx_tail_flags | rx->last_tail); in lan743x_rx_napi_poll()
2753 static void lan743x_rx_ring_cleanup(struct lan743x_rx *rx) in lan743x_rx_ring_cleanup() argument
2755 if (rx->buffer_info && rx->ring_cpu_ptr) { in lan743x_rx_ring_cleanup()
2758 for (index = 0; index < rx->ring_size; index++) in lan743x_rx_ring_cleanup()
2759 lan743x_rx_release_ring_element(rx, index); in lan743x_rx_ring_cleanup()
2762 if (rx->head_cpu_ptr) { in lan743x_rx_ring_cleanup()
2763 dma_free_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_cleanup()
2764 sizeof(*rx->head_cpu_ptr), rx->head_cpu_ptr, in lan743x_rx_ring_cleanup()
2765 rx->head_dma_ptr); in lan743x_rx_ring_cleanup()
2766 rx->head_cpu_ptr = NULL; in lan743x_rx_ring_cleanup()
2767 rx->head_dma_ptr = 0; in lan743x_rx_ring_cleanup()
2770 kfree(rx->buffer_info); in lan743x_rx_ring_cleanup()
2771 rx->buffer_info = NULL; in lan743x_rx_ring_cleanup()
2773 if (rx->ring_cpu_ptr) { in lan743x_rx_ring_cleanup()
2774 dma_free_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_cleanup()
2775 rx->ring_allocation_size, rx->ring_cpu_ptr, in lan743x_rx_ring_cleanup()
2776 rx->ring_dma_ptr); in lan743x_rx_ring_cleanup()
2777 rx->ring_allocation_size = 0; in lan743x_rx_ring_cleanup()
2778 rx->ring_cpu_ptr = NULL; in lan743x_rx_ring_cleanup()
2779 rx->ring_dma_ptr = 0; in lan743x_rx_ring_cleanup()
2782 rx->ring_size = 0; in lan743x_rx_ring_cleanup()
2783 rx->last_head = 0; in lan743x_rx_ring_cleanup()
2786 static int lan743x_rx_ring_init(struct lan743x_rx *rx) in lan743x_rx_ring_init() argument
2794 rx->ring_size = LAN743X_RX_RING_SIZE; in lan743x_rx_ring_init()
2795 if (rx->ring_size <= 1) { in lan743x_rx_ring_init()
2799 if (rx->ring_size & ~RX_CFG_B_RX_RING_LEN_MASK_) { in lan743x_rx_ring_init()
2803 if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2805 dev_warn(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2810 ring_allocation_size = ALIGN(rx->ring_size * in lan743x_rx_ring_init()
2814 cpu_ptr = dma_alloc_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2820 rx->ring_allocation_size = ring_allocation_size; in lan743x_rx_ring_init()
2821 rx->ring_cpu_ptr = (struct lan743x_rx_descriptor *)cpu_ptr; in lan743x_rx_ring_init()
2822 rx->ring_dma_ptr = dma_ptr; in lan743x_rx_ring_init()
2824 cpu_ptr = kcalloc(rx->ring_size, sizeof(*rx->buffer_info), in lan743x_rx_ring_init()
2830 rx->buffer_info = (struct lan743x_rx_buffer_info *)cpu_ptr; in lan743x_rx_ring_init()
2832 cpu_ptr = dma_alloc_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2833 sizeof(*rx->head_cpu_ptr), &dma_ptr, in lan743x_rx_ring_init()
2840 rx->head_cpu_ptr = cpu_ptr; in lan743x_rx_ring_init()
2841 rx->head_dma_ptr = dma_ptr; in lan743x_rx_ring_init()
2842 if (rx->head_dma_ptr & 0x3) { in lan743x_rx_ring_init()
2847 rx->last_head = 0; in lan743x_rx_ring_init()
2848 for (index = 0; index < rx->ring_size; index++) { in lan743x_rx_ring_init()
2849 ret = lan743x_rx_init_ring_element(rx, index, GFP_KERNEL); in lan743x_rx_ring_init()
2856 netif_warn(rx->adapter, ifup, rx->adapter->netdev, in lan743x_rx_ring_init()
2859 lan743x_rx_ring_cleanup(rx); in lan743x_rx_ring_init()
2863 static void lan743x_rx_close(struct lan743x_rx *rx) in lan743x_rx_close() argument
2865 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_close()
2868 FCT_RX_CTL_DIS_(rx->channel_number)); in lan743x_rx_close()
2870 FCT_RX_CTL_EN_(rx->channel_number), in lan743x_rx_close()
2874 DMAC_CMD_STOP_R_(rx->channel_number)); in lan743x_rx_close()
2875 lan743x_dmac_rx_wait_till_stopped(adapter, rx->channel_number); in lan743x_rx_close()
2878 DMAC_INT_BIT_RXFRM_(rx->channel_number)); in lan743x_rx_close()
2880 INT_BIT_DMA_RX_(rx->channel_number)); in lan743x_rx_close()
2881 napi_disable(&rx->napi); in lan743x_rx_close()
2883 netif_napi_del(&rx->napi); in lan743x_rx_close()
2885 lan743x_rx_ring_cleanup(rx); in lan743x_rx_close()
2888 static int lan743x_rx_open(struct lan743x_rx *rx) in lan743x_rx_open() argument
2890 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_open()
2894 rx->frame_count = 0; in lan743x_rx_open()
2895 ret = lan743x_rx_ring_init(rx); in lan743x_rx_open()
2899 netif_napi_add(adapter->netdev, &rx->napi, lan743x_rx_napi_poll); in lan743x_rx_open()
2902 DMAC_CMD_RX_SWR_(rx->channel_number)); in lan743x_rx_open()
2904 DMAC_CMD_RX_SWR_(rx->channel_number), in lan743x_rx_open()
2909 RX_BASE_ADDRH(rx->channel_number), in lan743x_rx_open()
2910 DMA_ADDR_HIGH32(rx->ring_dma_ptr)); in lan743x_rx_open()
2912 RX_BASE_ADDRL(rx->channel_number), in lan743x_rx_open()
2913 DMA_ADDR_LOW32(rx->ring_dma_ptr)); in lan743x_rx_open()
2917 RX_HEAD_WRITEBACK_ADDRH(rx->channel_number), in lan743x_rx_open()
2918 DMA_ADDR_HIGH32(rx->head_dma_ptr)); in lan743x_rx_open()
2920 RX_HEAD_WRITEBACK_ADDRL(rx->channel_number), in lan743x_rx_open()
2921 DMA_ADDR_LOW32(rx->head_dma_ptr)); in lan743x_rx_open()
2932 RX_CFG_A(rx->channel_number), data); in lan743x_rx_open()
2935 data = lan743x_csr_read(adapter, RX_CFG_B(rx->channel_number)); in lan743x_rx_open()
2942 data |= ((rx->ring_size) & RX_CFG_B_RX_RING_LEN_MASK_); in lan743x_rx_open()
2947 lan743x_csr_write(adapter, RX_CFG_B(rx->channel_number), data); in lan743x_rx_open()
2948 rx->vector_flags = lan743x_intr_get_vector_flags(adapter, in lan743x_rx_open()
2950 (rx->channel_number)); in lan743x_rx_open()
2954 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_CLEAR) in lan743x_rx_open()
2956 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_STATUS_AUTO_CLEAR) in lan743x_rx_open()
2958 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_STATUS_R2C) in lan743x_rx_open()
2960 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_ENABLE_R2C) in lan743x_rx_open()
2962 lan743x_csr_write(adapter, RX_CFG_C(rx->channel_number), data); in lan743x_rx_open()
2964 rx->last_tail = ((u32)(rx->ring_size - 1)); in lan743x_rx_open()
2965 lan743x_csr_write(adapter, RX_TAIL(rx->channel_number), in lan743x_rx_open()
2966 rx->last_tail); in lan743x_rx_open()
2967 rx->last_head = lan743x_csr_read(adapter, RX_HEAD(rx->channel_number)); in lan743x_rx_open()
2968 if (rx->last_head) { in lan743x_rx_open()
2973 napi_enable(&rx->napi); in lan743x_rx_open()
2976 INT_BIT_DMA_RX_(rx->channel_number)); in lan743x_rx_open()
2978 DMAC_INT_BIT_RXFRM_(rx->channel_number)); in lan743x_rx_open()
2980 DMAC_INT_BIT_RXFRM_(rx->channel_number)); in lan743x_rx_open()
2982 DMAC_CMD_START_R_(rx->channel_number)); in lan743x_rx_open()
2986 FCT_RX_CTL_RESET_(rx->channel_number)); in lan743x_rx_open()
2988 FCT_RX_CTL_RESET_(rx->channel_number), in lan743x_rx_open()
2990 lan743x_csr_write(adapter, FCT_FLOW(rx->channel_number), in lan743x_rx_open()
2997 FCT_RX_CTL_EN_(rx->channel_number)); in lan743x_rx_open()
3001 netif_napi_del(&rx->napi); in lan743x_rx_open()
3002 lan743x_rx_ring_cleanup(rx); in lan743x_rx_open()
3017 lan743x_rx_close(&adapter->rx[index]); in lan743x_netdev_close()
3055 ret = lan743x_rx_open(&adapter->rx[index]); in lan743x_netdev_open()
3086 if (adapter->rx[index].ring_cpu_ptr) in lan743x_netdev_open()
3087 lan743x_rx_close(&adapter->rx[index]); in lan743x_netdev_open()
3302 adapter->rx[index].adapter = adapter; in lan743x_hardware_init()
3303 adapter->rx[index].channel_number = index; in lan743x_hardware_init()