Lines Matching full:ch

130 static void xrx200_flush_dma(struct xrx200_chan *ch)  in xrx200_flush_dma()  argument
135 struct ltq_dma_desc *desc = &ch->dma.desc_base[ch->dma.desc]; in xrx200_flush_dma()
141 ch->priv->rx_buf_size; in xrx200_flush_dma()
142 ch->dma.desc++; in xrx200_flush_dma()
143 ch->dma.desc %= LTQ_DESC_NUM; in xrx200_flush_dma()
187 static int xrx200_alloc_buf(struct xrx200_chan *ch, void *(*alloc)(unsigned int size)) in xrx200_alloc_buf() argument
189 void *buf = ch->rx_buff[ch->dma.desc]; in xrx200_alloc_buf()
190 struct xrx200_priv *priv = ch->priv; in xrx200_alloc_buf()
194 ch->rx_buff[ch->dma.desc] = alloc(priv->rx_skb_size); in xrx200_alloc_buf()
195 if (!ch->rx_buff[ch->dma.desc]) { in xrx200_alloc_buf()
196 ch->rx_buff[ch->dma.desc] = buf; in xrx200_alloc_buf()
201 mapping = dma_map_single(priv->dev, ch->rx_buff[ch->dma.desc], in xrx200_alloc_buf()
204 skb_free_frag(ch->rx_buff[ch->dma.desc]); in xrx200_alloc_buf()
205 ch->rx_buff[ch->dma.desc] = buf; in xrx200_alloc_buf()
210 ch->dma.desc_base[ch->dma.desc].addr = mapping + NET_SKB_PAD + NET_IP_ALIGN; in xrx200_alloc_buf()
214 ch->dma.desc_base[ch->dma.desc].ctl = in xrx200_alloc_buf()
220 static int xrx200_hw_receive(struct xrx200_chan *ch) in xrx200_hw_receive() argument
222 struct xrx200_priv *priv = ch->priv; in xrx200_hw_receive()
223 struct ltq_dma_desc *desc = &ch->dma.desc_base[ch->dma.desc]; in xrx200_hw_receive()
224 void *buf = ch->rx_buff[ch->dma.desc]; in xrx200_hw_receive()
231 ret = xrx200_alloc_buf(ch, napi_alloc_frag); in xrx200_hw_receive()
233 ch->dma.desc++; in xrx200_hw_receive()
234 ch->dma.desc %= LTQ_DESC_NUM; in xrx200_hw_receive()
254 ch->skb_head = skb; in xrx200_hw_receive()
255 ch->skb_tail = skb; in xrx200_hw_receive()
257 } else if (ch->skb_head) { in xrx200_hw_receive()
258 if (ch->skb_head == ch->skb_tail) in xrx200_hw_receive()
259 skb_shinfo(ch->skb_tail)->frag_list = skb; in xrx200_hw_receive()
261 ch->skb_tail->next = skb; in xrx200_hw_receive()
262 ch->skb_tail = skb; in xrx200_hw_receive()
263 ch->skb_head->len += skb->len; in xrx200_hw_receive()
264 ch->skb_head->data_len += skb->len; in xrx200_hw_receive()
265 ch->skb_head->truesize += skb->truesize; in xrx200_hw_receive()
269 ch->skb_head->protocol = eth_type_trans(ch->skb_head, net_dev); in xrx200_hw_receive()
271 net_dev->stats.rx_bytes += ch->skb_head->len; in xrx200_hw_receive()
272 netif_receive_skb(ch->skb_head); in xrx200_hw_receive()
273 ch->skb_head = NULL; in xrx200_hw_receive()
274 ch->skb_tail = NULL; in xrx200_hw_receive()
285 struct xrx200_chan *ch = container_of(napi, in xrx200_poll_rx() local
291 struct ltq_dma_desc *desc = &ch->dma.desc_base[ch->dma.desc]; in xrx200_poll_rx()
294 ret = xrx200_hw_receive(ch); in xrx200_poll_rx()
306 if (napi_complete_done(&ch->napi, rx)) in xrx200_poll_rx()
307 ltq_dma_enable_irq(&ch->dma); in xrx200_poll_rx()
315 struct xrx200_chan *ch = container_of(napi, in xrx200_tx_housekeeping() local
317 struct net_device *net_dev = ch->priv->net_dev; in xrx200_tx_housekeeping()
323 struct ltq_dma_desc *desc = &ch->dma.desc_base[ch->tx_free]; in xrx200_tx_housekeeping()
326 struct sk_buff *skb = ch->skb[ch->tx_free]; in xrx200_tx_housekeeping()
330 ch->skb[ch->tx_free] = NULL; in xrx200_tx_housekeeping()
332 memset(&ch->dma.desc_base[ch->tx_free], 0, in xrx200_tx_housekeeping()
334 ch->tx_free++; in xrx200_tx_housekeeping()
335 ch->tx_free %= LTQ_DESC_NUM; in xrx200_tx_housekeeping()
343 netdev_completed_queue(ch->priv->net_dev, pkts, bytes); in xrx200_tx_housekeeping()
350 if (napi_complete_done(&ch->napi, pkts)) in xrx200_tx_housekeeping()
351 ltq_dma_enable_irq(&ch->dma); in xrx200_tx_housekeeping()
361 struct xrx200_chan *ch = &priv->chan_tx; in xrx200_start_xmit() local
362 struct ltq_dma_desc *desc = &ch->dma.desc_base[ch->dma.desc]; in xrx200_start_xmit()
375 if ((desc->ctl & (LTQ_DMA_OWN | LTQ_DMA_C)) || ch->skb[ch->dma.desc]) { in xrx200_start_xmit()
381 ch->skb[ch->dma.desc] = skb; in xrx200_start_xmit()
395 ch->dma.desc++; in xrx200_start_xmit()
396 ch->dma.desc %= LTQ_DESC_NUM; in xrx200_start_xmit()
397 if (ch->dma.desc == ch->tx_free) in xrx200_start_xmit()
472 struct xrx200_chan *ch = ptr; in xrx200_dma_irq() local
474 if (napi_schedule_prep(&ch->napi)) { in xrx200_dma_irq()
475 ltq_dma_disable_irq(&ch->dma); in xrx200_dma_irq()
476 __napi_schedule(&ch->napi); in xrx200_dma_irq()
479 ltq_dma_ack_irq(&ch->dma); in xrx200_dma_irq()