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()
247 priv->stats.rx_packets++; in moxart_rx_poll()
248 priv->stats.rx_bytes += len; in moxart_rx_poll()
250 priv->stats.multicast++; in moxart_rx_poll()
256 priv->rx_head = rx_head; in moxart_rx_poll()
263 priv->reg_imr |= RPKT_FINISH_M; in moxart_rx_poll()
264 writel(priv->reg_imr, priv->base + REG_INTERRUPT_MASK); in moxart_rx_poll()
271 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_tx_finished() local
272 unsigned tx_head = priv->tx_head; in moxart_tx_finished()
273 unsigned tx_tail = priv->tx_tail; in moxart_tx_finished()
276 dma_unmap_single(&ndev->dev, priv->tx_mapping[tx_tail], in moxart_tx_finished()
277 priv->tx_len[tx_tail], DMA_TO_DEVICE); in moxart_tx_finished()
279 priv->stats.tx_packets++; in moxart_tx_finished()
280 priv->stats.tx_bytes += priv->tx_skb[tx_tail]->len; in moxart_tx_finished()
282 dev_kfree_skb_irq(priv->tx_skb[tx_tail]); in moxart_tx_finished()
283 priv->tx_skb[tx_tail] = NULL; in moxart_tx_finished()
287 priv->tx_tail = tx_tail; in moxart_tx_finished()
293 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_interrupt() local
294 unsigned int ists = readl(priv->base + REG_INTERRUPT_STATUS); in moxart_mac_interrupt()
300 if (napi_schedule_prep(&priv->napi)) { in moxart_mac_interrupt()
301 priv->reg_imr &= ~RPKT_FINISH_M; in moxart_mac_interrupt()
302 writel(priv->reg_imr, priv->base + REG_INTERRUPT_MASK); in moxart_mac_interrupt()
303 __napi_schedule(&priv->napi); in moxart_mac_interrupt()
312 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_start_xmit() local
315 unsigned int tx_head = priv->tx_head; in moxart_mac_start_xmit()
319 desc = priv->tx_desc_base + (TX_REG_DESC_SIZE * tx_head); in moxart_mac_start_xmit()
321 spin_lock_irq(&priv->txlock); in moxart_mac_start_xmit()
324 priv->stats.tx_dropped++; in moxart_mac_start_xmit()
330 priv->tx_mapping[tx_head] = dma_map_single(&ndev->dev, skb->data, in moxart_mac_start_xmit()
332 if (dma_mapping_error(&ndev->dev, priv->tx_mapping[tx_head])) { in moxart_mac_start_xmit()
337 priv->tx_len[tx_head] = len; in moxart_mac_start_xmit()
338 priv->tx_skb[tx_head] = skb; in moxart_mac_start_xmit()
340 writel(priv->tx_mapping[tx_head], in moxart_mac_start_xmit()
351 dma_sync_single_for_device(&ndev->dev, priv->tx_mapping[tx_head], in moxart_mac_start_xmit()
352 priv->tx_buf_size, DMA_TO_DEVICE); in moxart_mac_start_xmit()
361 writel(0xffffffff, priv->base + REG_TX_POLL_DEMAND); in moxart_mac_start_xmit()
363 priv->tx_head = TX_NEXT(tx_head); in moxart_mac_start_xmit()
368 spin_unlock_irq(&priv->txlock); in moxart_mac_start_xmit()
375 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_get_stats() local
377 return &priv->stats; in moxart_mac_get_stats()
382 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_setmulticast() local
390 writel(readl(priv->base + REG_MCAST_HASH_TABLE1) | in moxart_mac_setmulticast()
392 priv->base + REG_MCAST_HASH_TABLE1); in moxart_mac_setmulticast()
394 writel(readl(priv->base + REG_MCAST_HASH_TABLE0) | in moxart_mac_setmulticast()
396 priv->base + REG_MCAST_HASH_TABLE0); in moxart_mac_setmulticast()
403 struct moxart_mac_priv_t *priv = netdev_priv(ndev); in moxart_mac_set_rx_mode() local
405 spin_lock_irq(&priv->txlock); in moxart_mac_set_rx_mode()
407 (ndev->flags & IFF_PROMISC) ? (priv->reg_maccr |= RCV_ALL) : in moxart_mac_set_rx_mode()
408 (priv->reg_maccr &= ~RCV_ALL); in moxart_mac_set_rx_mode()
410 (ndev->flags & IFF_ALLMULTI) ? (priv->reg_maccr |= RX_MULTIPKT) : in moxart_mac_set_rx_mode()
411 (priv->reg_maccr &= ~RX_MULTIPKT); in moxart_mac_set_rx_mode()
414 priv->reg_maccr |= HT_MULTI_EN; in moxart_mac_set_rx_mode()
417 priv->reg_maccr &= ~HT_MULTI_EN; in moxart_mac_set_rx_mode()
420 writel(priv->reg_maccr, priv->base + REG_MAC_CTRL); in moxart_mac_set_rx_mode()
422 spin_unlock_irq(&priv->txlock); in moxart_mac_set_rx_mode()
441 struct moxart_mac_priv_t *priv; in moxart_mac_probe() local
457 priv = netdev_priv(ndev); in moxart_mac_probe()
458 priv->ndev = ndev; in moxart_mac_probe()
462 priv->base = devm_ioremap_resource(p_dev, res); in moxart_mac_probe()
463 ret = IS_ERR(priv->base); in moxart_mac_probe()
469 spin_lock_init(&priv->txlock); in moxart_mac_probe()
471 priv->tx_buf_size = TX_BUF_SIZE; in moxart_mac_probe()
472 priv->rx_buf_size = RX_BUF_SIZE; in moxart_mac_probe()
474 priv->tx_desc_base = dma_alloc_coherent(NULL, TX_REG_DESC_SIZE * in moxart_mac_probe()
475 TX_DESC_NUM, &priv->tx_base, in moxart_mac_probe()
477 if (priv->tx_desc_base == NULL) { in moxart_mac_probe()
482 priv->rx_desc_base = dma_alloc_coherent(NULL, RX_REG_DESC_SIZE * in moxart_mac_probe()
483 RX_DESC_NUM, &priv->rx_base, in moxart_mac_probe()
485 if (priv->rx_desc_base == NULL) { in moxart_mac_probe()
490 priv->tx_buf_base = kmalloc(priv->tx_buf_size * TX_DESC_NUM, in moxart_mac_probe()
492 if (!priv->tx_buf_base) { in moxart_mac_probe()
497 priv->rx_buf_base = kmalloc(priv->rx_buf_size * RX_DESC_NUM, in moxart_mac_probe()
499 if (!priv->rx_buf_base) { in moxart_mac_probe()
514 netif_napi_add(ndev, &priv->napi, moxart_rx_poll, RX_DESC_NUM); in moxart_mac_probe()