Lines Matching refs:priv
34 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_emac_write() local
36 writel(value, priv->base + reg); in moxart_emac_write()
65 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_free_memory() local
69 dma_unmap_single(&ndev->dev, priv->rx_mapping[i], in moxart_mac_free_memory()
70 priv->rx_buf_size, DMA_FROM_DEVICE); in moxart_mac_free_memory()
72 if (priv->tx_desc_base) in moxart_mac_free_memory()
74 priv->tx_desc_base, priv->tx_base); in moxart_mac_free_memory()
76 if (priv->rx_desc_base) in moxart_mac_free_memory()
78 priv->rx_desc_base, priv->rx_base); in moxart_mac_free_memory()
80 kfree(priv->tx_buf_base); in moxart_mac_free_memory()
81 kfree(priv->rx_buf_base); in moxart_mac_free_memory()
86 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_reset() local
88 writel(SW_RST, priv->base + REG_MAC_CTRL); in moxart_mac_reset()
89 while (readl(priv->base + REG_MAC_CTRL) & SW_RST) in moxart_mac_reset()
92 writel(0, priv->base + REG_INTERRUPT_MASK); in moxart_mac_reset()
94 priv->reg_maccr = RX_BROADPKT | FULLDUP | CRC_APD | RX_FTL; in moxart_mac_reset()
99 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_enable() local
101 writel(0x00001010, priv->base + REG_INT_TIMER_CTRL); in moxart_mac_enable()
102 writel(0x00000001, priv->base + REG_APOLL_TIMER_CTRL); in moxart_mac_enable()
103 writel(0x00000390, priv->base + REG_DMA_BLEN_CTRL); in moxart_mac_enable()
105 priv->reg_imr |= (RPKT_FINISH_M | XPKT_FINISH_M); in moxart_mac_enable()
106 writel(priv->reg_imr, priv->base + REG_INTERRUPT_MASK); in moxart_mac_enable()
108 priv->reg_maccr |= (RCV_EN | XMT_EN | RDMA_EN | XDMA_EN); in moxart_mac_enable()
109 writel(priv->reg_maccr, priv->base + REG_MAC_CTRL); in moxart_mac_enable()
114 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_setup_desc_ring() local
119 desc = priv->tx_desc_base + i * TX_REG_DESC_SIZE; in moxart_mac_setup_desc_ring()
122 priv->tx_buf[i] = priv->tx_buf_base + priv->tx_buf_size * i; in moxart_mac_setup_desc_ring()
126 priv->tx_head = 0; in moxart_mac_setup_desc_ring()
127 priv->tx_tail = 0; in moxart_mac_setup_desc_ring()
130 desc = priv->rx_desc_base + i * RX_REG_DESC_SIZE; in moxart_mac_setup_desc_ring()
136 priv->rx_buf[i] = priv->rx_buf_base + priv->rx_buf_size * i; in moxart_mac_setup_desc_ring()
137 priv->rx_mapping[i] = dma_map_single(&ndev->dev, in moxart_mac_setup_desc_ring()
138 priv->rx_buf[i], in moxart_mac_setup_desc_ring()
139 priv->rx_buf_size, in moxart_mac_setup_desc_ring()
141 if (dma_mapping_error(&ndev->dev, priv->rx_mapping[i])) in moxart_mac_setup_desc_ring()
144 writel(priv->rx_mapping[i], in moxart_mac_setup_desc_ring()
146 writel(priv->rx_buf[i], in moxart_mac_setup_desc_ring()
151 priv->rx_head = 0; in moxart_mac_setup_desc_ring()
154 writel(priv->tx_base, priv->base + REG_TXR_BASE_ADDRESS); in moxart_mac_setup_desc_ring()
155 writel(priv->rx_base, priv->base + REG_RXR_BASE_ADDRESS); in moxart_mac_setup_desc_ring()
160 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_open() local
165 napi_enable(&priv->napi); in moxart_mac_open()
174 __func__, readl(priv->base + REG_INTERRUPT_MASK), in moxart_mac_open()
175 readl(priv->base + REG_MAC_CTRL)); in moxart_mac_open()
182 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_stop() local
184 napi_disable(&priv->napi); in moxart_mac_stop()
189 writel(0, priv->base + REG_INTERRUPT_MASK); in moxart_mac_stop()
192 writel(0, priv->base + REG_MAC_CTRL); in moxart_mac_stop()
199 struct moxart_mac_priv_t *priv = container_of(napi, in moxart_rx_poll() local
202 struct net_device *ndev = priv->ndev; in moxart_rx_poll()
206 int rx_head = priv->rx_head; in moxart_rx_poll()
210 desc = priv->rx_desc_base + (RX_REG_DESC_SIZE * rx_head); in moxart_rx_poll()
219 priv->stats.rx_dropped++; in moxart_rx_poll()
220 priv->stats.rx_errors++; in moxart_rx_poll()
230 priv->rx_mapping[rx_head], in moxart_rx_poll()
231 priv->rx_buf_size, DMA_FROM_DEVICE); in moxart_rx_poll()
236 priv->stats.rx_dropped++; in moxart_rx_poll()
237 priv->stats.rx_errors++; in moxart_rx_poll()
241 memcpy(skb->data, priv->rx_buf[rx_head], len); in moxart_rx_poll()
244 napi_gro_receive(&priv->napi, skb); in moxart_rx_poll()
248 priv->stats.rx_packets++; in moxart_rx_poll()
249 priv->stats.rx_bytes += len; in moxart_rx_poll()
251 priv->stats.multicast++; in moxart_rx_poll()
257 priv->rx_head = rx_head; in moxart_rx_poll()
264 priv->reg_imr |= RPKT_FINISH_M; in moxart_rx_poll()
265 writel(priv->reg_imr, priv->base + REG_INTERRUPT_MASK); in moxart_rx_poll()
272 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_tx_finished() local
273 unsigned tx_head = priv->tx_head; in moxart_tx_finished()
274 unsigned tx_tail = priv->tx_tail; in moxart_tx_finished()
277 dma_unmap_single(&ndev->dev, priv->tx_mapping[tx_tail], in moxart_tx_finished()
278 priv->tx_len[tx_tail], DMA_TO_DEVICE); in moxart_tx_finished()
280 priv->stats.tx_packets++; in moxart_tx_finished()
281 priv->stats.tx_bytes += priv->tx_skb[tx_tail]->len; in moxart_tx_finished()
283 dev_kfree_skb_irq(priv->tx_skb[tx_tail]); in moxart_tx_finished()
284 priv->tx_skb[tx_tail] = NULL; in moxart_tx_finished()
288 priv->tx_tail = tx_tail; in moxart_tx_finished()
294 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_interrupt() local
295 unsigned int ists = readl(priv->base + REG_INTERRUPT_STATUS); in moxart_mac_interrupt()
301 if (napi_schedule_prep(&priv->napi)) { in moxart_mac_interrupt()
302 priv->reg_imr &= ~RPKT_FINISH_M; in moxart_mac_interrupt()
303 writel(priv->reg_imr, priv->base + REG_INTERRUPT_MASK); in moxart_mac_interrupt()
304 __napi_schedule(&priv->napi); in moxart_mac_interrupt()
313 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_start_xmit() local
316 unsigned int tx_head = priv->tx_head; in moxart_mac_start_xmit()
320 desc = priv->tx_desc_base + (TX_REG_DESC_SIZE * tx_head); in moxart_mac_start_xmit()
322 spin_lock_irq(&priv->txlock); in moxart_mac_start_xmit()
325 priv->stats.tx_dropped++; in moxart_mac_start_xmit()
331 priv->tx_mapping[tx_head] = dma_map_single(&ndev->dev, skb->data, in moxart_mac_start_xmit()
333 if (dma_mapping_error(&ndev->dev, priv->tx_mapping[tx_head])) { in moxart_mac_start_xmit()
338 priv->tx_len[tx_head] = len; in moxart_mac_start_xmit()
339 priv->tx_skb[tx_head] = skb; in moxart_mac_start_xmit()
341 writel(priv->tx_mapping[tx_head], in moxart_mac_start_xmit()
352 dma_sync_single_for_device(&ndev->dev, priv->tx_mapping[tx_head], in moxart_mac_start_xmit()
353 priv->tx_buf_size, DMA_TO_DEVICE); in moxart_mac_start_xmit()
362 writel(0xffffffff, priv->base + REG_TX_POLL_DEMAND); in moxart_mac_start_xmit()
364 priv->tx_head = TX_NEXT(tx_head); in moxart_mac_start_xmit()
369 spin_unlock_irq(&priv->txlock); in moxart_mac_start_xmit()
376 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_get_stats() local
378 return &priv->stats; in moxart_mac_get_stats()
383 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_setmulticast() local
391 writel(readl(priv->base + REG_MCAST_HASH_TABLE1) | in moxart_mac_setmulticast()
393 priv->base + REG_MCAST_HASH_TABLE1); in moxart_mac_setmulticast()
395 writel(readl(priv->base + REG_MCAST_HASH_TABLE0) | in moxart_mac_setmulticast()
397 priv->base + REG_MCAST_HASH_TABLE0); in moxart_mac_setmulticast()
404 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_set_rx_mode() local
406 spin_lock_irq(&priv->txlock); in moxart_mac_set_rx_mode()
408 (ndev->flags & IFF_PROMISC) ? (priv->reg_maccr |= RCV_ALL) : in moxart_mac_set_rx_mode()
409 (priv->reg_maccr &= ~RCV_ALL); in moxart_mac_set_rx_mode()
411 (ndev->flags & IFF_ALLMULTI) ? (priv->reg_maccr |= RX_MULTIPKT) : in moxart_mac_set_rx_mode()
412 (priv->reg_maccr &= ~RX_MULTIPKT); in moxart_mac_set_rx_mode()
415 priv->reg_maccr |= HT_MULTI_EN; in moxart_mac_set_rx_mode()
418 priv->reg_maccr &= ~HT_MULTI_EN; in moxart_mac_set_rx_mode()
421 writel(priv->reg_maccr, priv->base + REG_MAC_CTRL); in moxart_mac_set_rx_mode()
423 spin_unlock_irq(&priv->txlock); in moxart_mac_set_rx_mode()
442 struct moxart_mac_priv_t *priv; in moxart_mac_probe() local
458 priv = netdev_priv(ndev); in moxart_mac_probe()
459 priv->ndev = ndev; in moxart_mac_probe()
463 priv->base = devm_ioremap_resource(p_dev, res); in moxart_mac_probe()
464 ret = IS_ERR(priv->base); in moxart_mac_probe()
470 spin_lock_init(&priv->txlock); in moxart_mac_probe()
472 priv->tx_buf_size = TX_BUF_SIZE; in moxart_mac_probe()
473 priv->rx_buf_size = RX_BUF_SIZE; in moxart_mac_probe()
475 priv->tx_desc_base = dma_alloc_coherent(NULL, TX_REG_DESC_SIZE * in moxart_mac_probe()
476 TX_DESC_NUM, &priv->tx_base, in moxart_mac_probe()
478 if (priv->tx_desc_base == NULL) { in moxart_mac_probe()
483 priv->rx_desc_base = dma_alloc_coherent(NULL, RX_REG_DESC_SIZE * in moxart_mac_probe()
484 RX_DESC_NUM, &priv->rx_base, in moxart_mac_probe()
486 if (priv->rx_desc_base == NULL) { in moxart_mac_probe()
491 priv->tx_buf_base = kmalloc(priv->tx_buf_size * TX_DESC_NUM, in moxart_mac_probe()
493 if (!priv->tx_buf_base) { in moxart_mac_probe()
498 priv->rx_buf_base = kmalloc(priv->rx_buf_size * RX_DESC_NUM, in moxart_mac_probe()
500 if (!priv->rx_buf_base) { in moxart_mac_probe()
515 netif_napi_add(ndev, &priv->napi, moxart_rx_poll, RX_DESC_NUM); in moxart_mac_probe()