Lines Matching refs:rx

259 	struct lan743x_rx *rx = context;  in lan743x_rx_isr()  local
260 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_isr()
265 INT_BIT_DMA_RX_(rx->channel_number)); in lan743x_rx_isr()
268 if (int_sts & INT_BIT_DMA_RX_(rx->channel_number)) { in lan743x_rx_isr()
269 u32 rx_frame_bit = DMAC_INT_BIT_RXFRM_(rx->channel_number); in lan743x_rx_isr()
286 napi_schedule(&rx->napi); in lan743x_rx_isr()
294 INT_BIT_DMA_RX_(rx->channel_number)); in lan743x_rx_isr()
309 lan743x_rx_isr(&adapter->rx[channel], in lan743x_intr_shared_isr()
729 &adapter->rx[index]); in lan743x_intr_open()
2436 static int lan743x_rx_next_index(struct lan743x_rx *rx, int index) in lan743x_rx_next_index() argument
2438 return ((++index) % rx->ring_size); in lan743x_rx_next_index()
2441 static void lan743x_rx_update_tail(struct lan743x_rx *rx, int index) in lan743x_rx_update_tail() argument
2445 lan743x_csr_write(rx->adapter, RX_TAIL(rx->channel_number), in lan743x_rx_update_tail()
2449 static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index, in lan743x_rx_init_ring_element() argument
2452 struct net_device *netdev = rx->adapter->netdev; in lan743x_rx_init_ring_element()
2453 struct device *dev = &rx->adapter->pdev->dev; in lan743x_rx_init_ring_element()
2462 descriptor = &rx->ring_cpu_ptr[index]; in lan743x_rx_init_ring_element()
2463 buffer_info = &rx->buffer_info[index]; in lan743x_rx_init_ring_element()
2501 lan743x_rx_update_tail(rx, index); in lan743x_rx_init_ring_element()
2506 static void lan743x_rx_reuse_ring_element(struct lan743x_rx *rx, int index) in lan743x_rx_reuse_ring_element() argument
2511 descriptor = &rx->ring_cpu_ptr[index]; in lan743x_rx_reuse_ring_element()
2512 buffer_info = &rx->buffer_info[index]; in lan743x_rx_reuse_ring_element()
2520 lan743x_rx_update_tail(rx, index); in lan743x_rx_reuse_ring_element()
2523 static void lan743x_rx_release_ring_element(struct lan743x_rx *rx, int index) in lan743x_rx_release_ring_element() argument
2528 descriptor = &rx->ring_cpu_ptr[index]; in lan743x_rx_release_ring_element()
2529 buffer_info = &rx->buffer_info[index]; in lan743x_rx_release_ring_element()
2534 dma_unmap_single(&rx->adapter->pdev->dev, in lan743x_rx_release_ring_element()
2564 static int lan743x_rx_process_buffer(struct lan743x_rx *rx) in lan743x_rx_process_buffer() argument
2566 int current_head_index = le32_to_cpu(*rx->head_cpu_ptr); in lan743x_rx_process_buffer()
2568 struct net_device *netdev = rx->adapter->netdev; in lan743x_rx_process_buffer()
2577 if (current_head_index < 0 || current_head_index >= rx->ring_size) in lan743x_rx_process_buffer()
2580 if (rx->last_head < 0 || rx->last_head >= rx->ring_size) in lan743x_rx_process_buffer()
2583 if (rx->last_head == current_head_index) in lan743x_rx_process_buffer()
2586 descriptor = &rx->ring_cpu_ptr[rx->last_head]; in lan743x_rx_process_buffer()
2589 buffer_info = &rx->buffer_info[rx->last_head]; in lan743x_rx_process_buffer()
2596 int index = lan743x_rx_next_index(rx, rx->last_head); in lan743x_rx_process_buffer()
2601 desc_ext = &rx->ring_cpu_ptr[index]; in lan743x_rx_process_buffer()
2630 if (lan743x_rx_init_ring_element(rx, rx->last_head, in lan743x_rx_process_buffer()
2636 lan743x_rx_reuse_ring_element(rx, rx->last_head); in lan743x_rx_process_buffer()
2638 dev_kfree_skb_irq(rx->skb_head); in lan743x_rx_process_buffer()
2639 rx->skb_head = NULL; in lan743x_rx_process_buffer()
2647 if (rx->skb_head) in lan743x_rx_process_buffer()
2648 dev_kfree_skb_irq(rx->skb_head); in lan743x_rx_process_buffer()
2649 rx->skb_head = skb; in lan743x_rx_process_buffer()
2650 } else if (rx->skb_head) { in lan743x_rx_process_buffer()
2652 if (skb_shinfo(rx->skb_head)->frag_list) in lan743x_rx_process_buffer()
2653 rx->skb_tail->next = skb; in lan743x_rx_process_buffer()
2655 skb_shinfo(rx->skb_head)->frag_list = skb; in lan743x_rx_process_buffer()
2656 rx->skb_tail = skb; in lan743x_rx_process_buffer()
2657 rx->skb_head->len += skb->len; in lan743x_rx_process_buffer()
2658 rx->skb_head->data_len += skb->len; in lan743x_rx_process_buffer()
2659 rx->skb_head->truesize += skb->truesize; in lan743x_rx_process_buffer()
2676 if (rx->skb_head) in lan743x_rx_process_buffer()
2677 skb_hwtstamps(rx->skb_head)->hwtstamp = in lan743x_rx_process_buffer()
2679 lan743x_rx_reuse_ring_element(rx, extension_index); in lan743x_rx_process_buffer()
2680 rx->last_head = extension_index; in lan743x_rx_process_buffer()
2684 if (is_last && rx->skb_head) in lan743x_rx_process_buffer()
2685 rx->skb_head = lan743x_rx_trim_skb(rx->skb_head, frame_length); in lan743x_rx_process_buffer()
2687 if (is_last && rx->skb_head) { in lan743x_rx_process_buffer()
2688 rx->skb_head->protocol = eth_type_trans(rx->skb_head, in lan743x_rx_process_buffer()
2689 rx->adapter->netdev); in lan743x_rx_process_buffer()
2690 if (rx->adapter->netdev->features & NETIF_F_RXCSUM) { in lan743x_rx_process_buffer()
2695 rx->skb_head->len); in lan743x_rx_process_buffer()
2696 napi_gro_receive(&rx->napi, rx->skb_head); in lan743x_rx_process_buffer()
2697 rx->skb_head = NULL; in lan743x_rx_process_buffer()
2702 rx->last_tail = rx->last_head; in lan743x_rx_process_buffer()
2703 rx->last_head = lan743x_rx_next_index(rx, rx->last_head); in lan743x_rx_process_buffer()
2711 struct lan743x_rx *rx = container_of(napi, struct lan743x_rx, napi); in lan743x_rx_napi_poll() local
2712 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_napi_poll()
2717 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_STATUS_W2C) { in lan743x_rx_napi_poll()
2720 DMAC_INT_BIT_RXFRM_(rx->channel_number)); in lan743x_rx_napi_poll()
2723 result = lan743x_rx_process_buffer(rx); in lan743x_rx_napi_poll()
2727 rx->frame_count += count; in lan743x_rx_napi_poll()
2735 if (rx->vector_flags & LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_SET) in lan743x_rx_napi_poll()
2737 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_SET) { in lan743x_rx_napi_poll()
2741 INT_BIT_DMA_RX_(rx->channel_number)); in lan743x_rx_napi_poll()
2745 lan743x_csr_write(adapter, RX_TAIL(rx->channel_number), in lan743x_rx_napi_poll()
2746 rx_tail_flags | rx->last_tail); in lan743x_rx_napi_poll()
2751 static void lan743x_rx_ring_cleanup(struct lan743x_rx *rx) in lan743x_rx_ring_cleanup() argument
2753 if (rx->buffer_info && rx->ring_cpu_ptr) { in lan743x_rx_ring_cleanup()
2756 for (index = 0; index < rx->ring_size; index++) in lan743x_rx_ring_cleanup()
2757 lan743x_rx_release_ring_element(rx, index); in lan743x_rx_ring_cleanup()
2760 if (rx->head_cpu_ptr) { in lan743x_rx_ring_cleanup()
2761 dma_free_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_cleanup()
2762 sizeof(*rx->head_cpu_ptr), rx->head_cpu_ptr, in lan743x_rx_ring_cleanup()
2763 rx->head_dma_ptr); in lan743x_rx_ring_cleanup()
2764 rx->head_cpu_ptr = NULL; in lan743x_rx_ring_cleanup()
2765 rx->head_dma_ptr = 0; in lan743x_rx_ring_cleanup()
2768 kfree(rx->buffer_info); in lan743x_rx_ring_cleanup()
2769 rx->buffer_info = NULL; in lan743x_rx_ring_cleanup()
2771 if (rx->ring_cpu_ptr) { in lan743x_rx_ring_cleanup()
2772 dma_free_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_cleanup()
2773 rx->ring_allocation_size, rx->ring_cpu_ptr, in lan743x_rx_ring_cleanup()
2774 rx->ring_dma_ptr); in lan743x_rx_ring_cleanup()
2775 rx->ring_allocation_size = 0; in lan743x_rx_ring_cleanup()
2776 rx->ring_cpu_ptr = NULL; in lan743x_rx_ring_cleanup()
2777 rx->ring_dma_ptr = 0; in lan743x_rx_ring_cleanup()
2780 rx->ring_size = 0; in lan743x_rx_ring_cleanup()
2781 rx->last_head = 0; in lan743x_rx_ring_cleanup()
2784 static int lan743x_rx_ring_init(struct lan743x_rx *rx) in lan743x_rx_ring_init() argument
2792 rx->ring_size = LAN743X_RX_RING_SIZE; in lan743x_rx_ring_init()
2793 if (rx->ring_size <= 1) { in lan743x_rx_ring_init()
2797 if (rx->ring_size & ~RX_CFG_B_RX_RING_LEN_MASK_) { in lan743x_rx_ring_init()
2801 if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2803 dev_warn(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2808 ring_allocation_size = ALIGN(rx->ring_size * in lan743x_rx_ring_init()
2812 cpu_ptr = dma_alloc_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2818 rx->ring_allocation_size = ring_allocation_size; in lan743x_rx_ring_init()
2819 rx->ring_cpu_ptr = (struct lan743x_rx_descriptor *)cpu_ptr; in lan743x_rx_ring_init()
2820 rx->ring_dma_ptr = dma_ptr; in lan743x_rx_ring_init()
2822 cpu_ptr = kcalloc(rx->ring_size, sizeof(*rx->buffer_info), in lan743x_rx_ring_init()
2828 rx->buffer_info = (struct lan743x_rx_buffer_info *)cpu_ptr; in lan743x_rx_ring_init()
2830 cpu_ptr = dma_alloc_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2831 sizeof(*rx->head_cpu_ptr), &dma_ptr, in lan743x_rx_ring_init()
2838 rx->head_cpu_ptr = cpu_ptr; in lan743x_rx_ring_init()
2839 rx->head_dma_ptr = dma_ptr; in lan743x_rx_ring_init()
2840 if (rx->head_dma_ptr & 0x3) { in lan743x_rx_ring_init()
2845 rx->last_head = 0; in lan743x_rx_ring_init()
2846 for (index = 0; index < rx->ring_size; index++) { in lan743x_rx_ring_init()
2847 ret = lan743x_rx_init_ring_element(rx, index, GFP_KERNEL); in lan743x_rx_ring_init()
2854 netif_warn(rx->adapter, ifup, rx->adapter->netdev, in lan743x_rx_ring_init()
2857 lan743x_rx_ring_cleanup(rx); in lan743x_rx_ring_init()
2861 static void lan743x_rx_close(struct lan743x_rx *rx) in lan743x_rx_close() argument
2863 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_close()
2866 FCT_RX_CTL_DIS_(rx->channel_number)); in lan743x_rx_close()
2868 FCT_RX_CTL_EN_(rx->channel_number), in lan743x_rx_close()
2872 DMAC_CMD_STOP_R_(rx->channel_number)); in lan743x_rx_close()
2873 lan743x_dmac_rx_wait_till_stopped(adapter, rx->channel_number); in lan743x_rx_close()
2876 DMAC_INT_BIT_RXFRM_(rx->channel_number)); in lan743x_rx_close()
2878 INT_BIT_DMA_RX_(rx->channel_number)); in lan743x_rx_close()
2879 napi_disable(&rx->napi); in lan743x_rx_close()
2881 netif_napi_del(&rx->napi); in lan743x_rx_close()
2883 lan743x_rx_ring_cleanup(rx); in lan743x_rx_close()
2886 static int lan743x_rx_open(struct lan743x_rx *rx) in lan743x_rx_open() argument
2888 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_open()
2892 rx->frame_count = 0; in lan743x_rx_open()
2893 ret = lan743x_rx_ring_init(rx); in lan743x_rx_open()
2897 netif_napi_add(adapter->netdev, &rx->napi, lan743x_rx_napi_poll); in lan743x_rx_open()
2900 DMAC_CMD_RX_SWR_(rx->channel_number)); in lan743x_rx_open()
2902 DMAC_CMD_RX_SWR_(rx->channel_number), in lan743x_rx_open()
2907 RX_BASE_ADDRH(rx->channel_number), in lan743x_rx_open()
2908 DMA_ADDR_HIGH32(rx->ring_dma_ptr)); in lan743x_rx_open()
2910 RX_BASE_ADDRL(rx->channel_number), in lan743x_rx_open()
2911 DMA_ADDR_LOW32(rx->ring_dma_ptr)); in lan743x_rx_open()
2915 RX_HEAD_WRITEBACK_ADDRH(rx->channel_number), in lan743x_rx_open()
2916 DMA_ADDR_HIGH32(rx->head_dma_ptr)); in lan743x_rx_open()
2918 RX_HEAD_WRITEBACK_ADDRL(rx->channel_number), in lan743x_rx_open()
2919 DMA_ADDR_LOW32(rx->head_dma_ptr)); in lan743x_rx_open()
2930 RX_CFG_A(rx->channel_number), data); in lan743x_rx_open()
2933 data = lan743x_csr_read(adapter, RX_CFG_B(rx->channel_number)); in lan743x_rx_open()
2940 data |= ((rx->ring_size) & RX_CFG_B_RX_RING_LEN_MASK_); in lan743x_rx_open()
2945 lan743x_csr_write(adapter, RX_CFG_B(rx->channel_number), data); in lan743x_rx_open()
2946 rx->vector_flags = lan743x_intr_get_vector_flags(adapter, in lan743x_rx_open()
2948 (rx->channel_number)); in lan743x_rx_open()
2952 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_CLEAR) in lan743x_rx_open()
2954 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_STATUS_AUTO_CLEAR) in lan743x_rx_open()
2956 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_STATUS_R2C) in lan743x_rx_open()
2958 if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_ENABLE_R2C) in lan743x_rx_open()
2960 lan743x_csr_write(adapter, RX_CFG_C(rx->channel_number), data); in lan743x_rx_open()
2962 rx->last_tail = ((u32)(rx->ring_size - 1)); in lan743x_rx_open()
2963 lan743x_csr_write(adapter, RX_TAIL(rx->channel_number), in lan743x_rx_open()
2964 rx->last_tail); in lan743x_rx_open()
2965 rx->last_head = lan743x_csr_read(adapter, RX_HEAD(rx->channel_number)); in lan743x_rx_open()
2966 if (rx->last_head) { in lan743x_rx_open()
2971 napi_enable(&rx->napi); in lan743x_rx_open()
2974 INT_BIT_DMA_RX_(rx->channel_number)); in lan743x_rx_open()
2976 DMAC_INT_BIT_RXFRM_(rx->channel_number)); in lan743x_rx_open()
2978 DMAC_INT_BIT_RXFRM_(rx->channel_number)); in lan743x_rx_open()
2980 DMAC_CMD_START_R_(rx->channel_number)); in lan743x_rx_open()
2984 FCT_RX_CTL_RESET_(rx->channel_number)); in lan743x_rx_open()
2986 FCT_RX_CTL_RESET_(rx->channel_number), in lan743x_rx_open()
2988 lan743x_csr_write(adapter, FCT_FLOW(rx->channel_number), in lan743x_rx_open()
2995 FCT_RX_CTL_EN_(rx->channel_number)); in lan743x_rx_open()
2999 netif_napi_del(&rx->napi); in lan743x_rx_open()
3000 lan743x_rx_ring_cleanup(rx); in lan743x_rx_open()
3015 lan743x_rx_close(&adapter->rx[index]); in lan743x_netdev_close()
3053 ret = lan743x_rx_open(&adapter->rx[index]); in lan743x_netdev_open()
3073 if (adapter->rx[index].ring_cpu_ptr) in lan743x_netdev_open()
3074 lan743x_rx_close(&adapter->rx[index]); in lan743x_netdev_open()
3273 adapter->rx[index].adapter = adapter; in lan743x_hardware_init()
3274 adapter->rx[index].channel_number = index; in lan743x_hardware_init()