Lines Matching refs:lp
45 struct sonic_local *lp = netdev_priv(dev); in sonic_msg_init() local
47 lp->msg_enable = netif_msg_init(sonic_debug, 0); in sonic_msg_init()
50 netif_dbg(lp, drv, dev, "%s", version); in sonic_msg_init()
55 struct sonic_local *lp = netdev_priv(dev); in sonic_alloc_descriptors() local
61 lp->descriptors = in sonic_alloc_descriptors()
62 dma_alloc_coherent(lp->device, in sonic_alloc_descriptors()
64 SONIC_BUS_SCALE(lp->dma_bitmode), in sonic_alloc_descriptors()
65 &lp->descriptors_laddr, GFP_KERNEL); in sonic_alloc_descriptors()
67 if (!lp->descriptors) in sonic_alloc_descriptors()
70 lp->cda = lp->descriptors; in sonic_alloc_descriptors()
71 lp->tda = lp->cda + SIZEOF_SONIC_CDA * in sonic_alloc_descriptors()
72 SONIC_BUS_SCALE(lp->dma_bitmode); in sonic_alloc_descriptors()
73 lp->rda = lp->tda + SIZEOF_SONIC_TD * SONIC_NUM_TDS * in sonic_alloc_descriptors()
74 SONIC_BUS_SCALE(lp->dma_bitmode); in sonic_alloc_descriptors()
75 lp->rra = lp->rda + SIZEOF_SONIC_RD * SONIC_NUM_RDS * in sonic_alloc_descriptors()
76 SONIC_BUS_SCALE(lp->dma_bitmode); in sonic_alloc_descriptors()
78 lp->cda_laddr = lp->descriptors_laddr; in sonic_alloc_descriptors()
79 lp->tda_laddr = lp->cda_laddr + SIZEOF_SONIC_CDA * in sonic_alloc_descriptors()
80 SONIC_BUS_SCALE(lp->dma_bitmode); in sonic_alloc_descriptors()
81 lp->rda_laddr = lp->tda_laddr + SIZEOF_SONIC_TD * SONIC_NUM_TDS * in sonic_alloc_descriptors()
82 SONIC_BUS_SCALE(lp->dma_bitmode); in sonic_alloc_descriptors()
83 lp->rra_laddr = lp->rda_laddr + SIZEOF_SONIC_RD * SONIC_NUM_RDS * in sonic_alloc_descriptors()
84 SONIC_BUS_SCALE(lp->dma_bitmode); in sonic_alloc_descriptors()
98 struct sonic_local *lp = netdev_priv(dev); in sonic_open() local
101 netif_dbg(lp, ifup, dev, "%s: initializing sonic driver\n", __func__); in sonic_open()
103 spin_lock_init(&lp->lock); in sonic_open()
110 dev_kfree_skb(lp->rx_skb[i]); in sonic_open()
111 lp->rx_skb[i] = NULL; in sonic_open()
118 if (SONIC_BUS_SCALE(lp->dma_bitmode) == 2) in sonic_open()
120 lp->rx_skb[i] = skb; in sonic_open()
124 dma_addr_t laddr = dma_map_single(lp->device, skb_put(lp->rx_skb[i], SONIC_RBSIZE), in sonic_open()
126 if (dma_mapping_error(lp->device, laddr)) { in sonic_open()
129 dma_unmap_single(lp->device, lp->rx_laddr[i], SONIC_RBSIZE, DMA_FROM_DEVICE); in sonic_open()
130 lp->rx_laddr[i] = (dma_addr_t)0; in sonic_open()
133 dev_kfree_skb(lp->rx_skb[i]); in sonic_open()
134 lp->rx_skb[i] = NULL; in sonic_open()
140 lp->rx_laddr[i] = laddr; in sonic_open()
150 netif_dbg(lp, ifup, dev, "%s: Initialization done\n", __func__); in sonic_open()
158 struct sonic_local * __maybe_unused lp = netdev_priv(dev); in sonic_quiesce() local
179 struct sonic_local *lp = netdev_priv(dev); in sonic_close() local
182 netif_dbg(lp, ifdown, dev, "%s\n", __func__); in sonic_close()
198 if(lp->tx_laddr[i]) { in sonic_close()
199 dma_unmap_single(lp->device, lp->tx_laddr[i], lp->tx_len[i], DMA_TO_DEVICE); in sonic_close()
200 lp->tx_laddr[i] = (dma_addr_t)0; in sonic_close()
202 if(lp->tx_skb[i]) { in sonic_close()
203 dev_kfree_skb(lp->tx_skb[i]); in sonic_close()
204 lp->tx_skb[i] = NULL; in sonic_close()
210 if(lp->rx_laddr[i]) { in sonic_close()
211 dma_unmap_single(lp->device, lp->rx_laddr[i], SONIC_RBSIZE, DMA_FROM_DEVICE); in sonic_close()
212 lp->rx_laddr[i] = (dma_addr_t)0; in sonic_close()
214 if(lp->rx_skb[i]) { in sonic_close()
215 dev_kfree_skb(lp->rx_skb[i]); in sonic_close()
216 lp->rx_skb[i] = NULL; in sonic_close()
225 struct sonic_local *lp = netdev_priv(dev); in sonic_tx_timeout() local
239 if(lp->tx_laddr[i]) { in sonic_tx_timeout()
240 dma_unmap_single(lp->device, lp->tx_laddr[i], lp->tx_len[i], DMA_TO_DEVICE); in sonic_tx_timeout()
241 lp->tx_laddr[i] = (dma_addr_t)0; in sonic_tx_timeout()
243 if(lp->tx_skb[i]) { in sonic_tx_timeout()
244 dev_kfree_skb(lp->tx_skb[i]); in sonic_tx_timeout()
245 lp->tx_skb[i] = NULL; in sonic_tx_timeout()
250 lp->stats.tx_errors++; in sonic_tx_timeout()
275 struct sonic_local *lp = netdev_priv(dev); in sonic_send_packet() local
281 netif_dbg(lp, tx_queued, dev, "%s: skb=%p\n", __func__, skb); in sonic_send_packet()
294 laddr = dma_map_single(lp->device, skb->data, length, DMA_TO_DEVICE); in sonic_send_packet()
301 spin_lock_irqsave(&lp->lock, flags); in sonic_send_packet()
303 entry = (lp->eol_tx + 1) & SONIC_TDS_MASK; in sonic_send_packet()
314 sonic_tda_put(dev, lp->eol_tx, SONIC_TD_LINK, ~SONIC_EOL & in sonic_send_packet()
315 sonic_tda_get(dev, lp->eol_tx, SONIC_TD_LINK)); in sonic_send_packet()
317 netif_dbg(lp, tx_queued, dev, "%s: issuing Tx command\n", __func__); in sonic_send_packet()
321 lp->tx_len[entry] = length; in sonic_send_packet()
322 lp->tx_laddr[entry] = laddr; in sonic_send_packet()
323 lp->tx_skb[entry] = skb; in sonic_send_packet()
325 lp->eol_tx = entry; in sonic_send_packet()
328 if (lp->tx_skb[entry]) { in sonic_send_packet()
330 netif_dbg(lp, tx_queued, dev, "%s: stopping queue\n", __func__); in sonic_send_packet()
335 spin_unlock_irqrestore(&lp->lock, flags); in sonic_send_packet()
347 struct sonic_local *lp = netdev_priv(dev); in sonic_interrupt() local
356 spin_lock_irqsave(&lp->lock, flags); in sonic_interrupt()
360 spin_unlock_irqrestore(&lp->lock, flags); in sonic_interrupt()
369 netif_dbg(lp, intr, dev, "%s: packet rx\n", __func__); in sonic_interrupt()
374 int entry = lp->cur_tx; in sonic_interrupt()
386 netif_dbg(lp, intr, dev, "%s: tx done\n", __func__); in sonic_interrupt()
388 while (lp->tx_skb[entry] != NULL) { in sonic_interrupt()
393 lp->stats.tx_packets++; in sonic_interrupt()
394 lp->stats.tx_bytes += sonic_tda_get(dev, entry, SONIC_TD_PKTSIZE); in sonic_interrupt()
398 lp->stats.tx_aborted_errors++; in sonic_interrupt()
401 lp->stats.tx_carrier_errors++; in sonic_interrupt()
403 lp->stats.tx_window_errors++; in sonic_interrupt()
405 lp->stats.tx_fifo_errors++; in sonic_interrupt()
409 dev_consume_skb_irq(lp->tx_skb[entry]); in sonic_interrupt()
410 lp->tx_skb[entry] = NULL; in sonic_interrupt()
412 dma_unmap_single(lp->device, lp->tx_laddr[entry], lp->tx_len[entry], DMA_TO_DEVICE); in sonic_interrupt()
413 lp->tx_laddr[entry] = (dma_addr_t)0; in sonic_interrupt()
423 if (freed_some || lp->tx_skb[entry] == NULL) in sonic_interrupt()
425 lp->cur_tx = entry; in sonic_interrupt()
432 netif_dbg(lp, rx_err, dev, "%s: rx fifo overrun\n", in sonic_interrupt()
436 netif_dbg(lp, rx_err, dev, "%s: rx descriptors exhausted\n", in sonic_interrupt()
440 netif_dbg(lp, rx_err, dev, "%s: rx buffer area exceeded\n", in sonic_interrupt()
446 lp->stats.rx_frame_errors += 65536; in sonic_interrupt()
448 lp->stats.rx_crc_errors += 65536; in sonic_interrupt()
450 lp->stats.rx_missed_errors += 65536; in sonic_interrupt()
456 netif_dbg(lp, tx_err, dev, "%s: TXER intr, TCR %04x\n", in sonic_interrupt()
479 spin_unlock_irqrestore(&lp->lock, flags); in sonic_interrupt()
485 static int index_from_addr(struct sonic_local *lp, dma_addr_t addr, in index_from_addr() argument
492 if (addr == lp->rx_laddr[i]) in index_from_addr()
500 static bool sonic_alloc_rb(struct net_device *dev, struct sonic_local *lp, in sonic_alloc_rb() argument
507 if (SONIC_BUS_SCALE(lp->dma_bitmode) == 2) in sonic_alloc_rb()
510 *new_addr = dma_map_single(lp->device, skb_put(*new_skb, SONIC_RBSIZE), in sonic_alloc_rb()
522 static void sonic_update_rra(struct net_device *dev, struct sonic_local *lp, in sonic_update_rra() argument
557 struct sonic_local *lp = netdev_priv(dev); in sonic_rx() local
558 int entry = lp->cur_rx; in sonic_rx()
559 int prev_entry = lp->eol_rx; in sonic_rx()
572 int i = index_from_addr(lp, addr, entry); in sonic_rx()
579 if (sonic_alloc_rb(dev, lp, &new_skb, &new_laddr)) { in sonic_rx()
580 struct sk_buff *used_skb = lp->rx_skb[i]; in sonic_rx()
584 dma_unmap_single(lp->device, addr, SONIC_RBSIZE, in sonic_rx()
593 lp->stats.rx_packets++; in sonic_rx()
594 lp->stats.rx_bytes += pkt_len; in sonic_rx()
596 lp->rx_skb[i] = new_skb; in sonic_rx()
597 lp->rx_laddr[i] = new_laddr; in sonic_rx()
601 lp->stats.rx_dropped++; in sonic_rx()
607 sonic_update_rra(dev, lp, addr, new_laddr); in sonic_rx()
619 lp->cur_rx = entry; in sonic_rx()
621 if (prev_entry != lp->eol_rx) { in sonic_rx()
625 sonic_rda_put(dev, lp->eol_rx, SONIC_RD_LINK, ~SONIC_EOL & in sonic_rx()
626 sonic_rda_get(dev, lp->eol_rx, SONIC_RD_LINK)); in sonic_rx()
627 lp->eol_rx = prev_entry; in sonic_rx()
641 struct sonic_local *lp = netdev_priv(dev); in sonic_get_stats() local
644 lp->stats.rx_crc_errors += SONIC_READ(SONIC_CRCT); in sonic_get_stats()
646 lp->stats.rx_frame_errors += SONIC_READ(SONIC_FAET); in sonic_get_stats()
648 lp->stats.rx_missed_errors += SONIC_READ(SONIC_MPT); in sonic_get_stats()
651 return &lp->stats; in sonic_get_stats()
660 struct sonic_local *lp = netdev_priv(dev); in sonic_multicast_list() local
678 netif_dbg(lp, ifup, dev, "%s: mc_count %d\n", __func__, in sonic_multicast_list()
691 SONIC_WRITE(SONIC_CDP, lp->cda_laddr & 0xffff); in sonic_multicast_list()
694 spin_lock_irqsave(&lp->lock, flags); in sonic_multicast_list()
698 spin_unlock_irqrestore(&lp->lock, flags); in sonic_multicast_list()
702 netif_dbg(lp, ifup, dev, "%s: setting RCR=%x\n", __func__, rcr); in sonic_multicast_list()
713 struct sonic_local *lp = netdev_priv(dev); in sonic_init() local
738 netif_dbg(lp, ifup, dev, "%s: initialize receive resource area\n", in sonic_init()
742 u16 bufadr_l = (unsigned long)lp->rx_laddr[i] & 0xffff; in sonic_init()
743 u16 bufadr_h = (unsigned long)lp->rx_laddr[i] >> 16; in sonic_init()
755 SONIC_WRITE(SONIC_URRA, lp->rra_laddr >> 16); in sonic_init()
756 SONIC_WRITE(SONIC_EOBC, (SONIC_RBSIZE >> 1) - (lp->dma_bitmode ? 2 : 1)); in sonic_init()
759 netif_dbg(lp, ifup, dev, "%s: issuing RRRA command\n", __func__); in sonic_init()
769 netif_dbg(lp, ifup, dev, "%s: initialize receive descriptors\n", in sonic_init()
780 lp->rda_laddr + in sonic_init()
781 ((i+1) * SIZEOF_SONIC_RD * SONIC_BUS_SCALE(lp->dma_bitmode))); in sonic_init()
785 (lp->rda_laddr & 0xffff) | SONIC_EOL); in sonic_init()
786 lp->eol_rx = SONIC_NUM_RDS - 1; in sonic_init()
787 lp->cur_rx = 0; in sonic_init()
788 SONIC_WRITE(SONIC_URDA, lp->rda_laddr >> 16); in sonic_init()
789 SONIC_WRITE(SONIC_CRDA, lp->rda_laddr & 0xffff); in sonic_init()
794 netif_dbg(lp, ifup, dev, "%s: initialize transmit descriptors\n", in sonic_init()
803 (lp->tda_laddr & 0xffff) + in sonic_init()
804 (i + 1) * SIZEOF_SONIC_TD * SONIC_BUS_SCALE(lp->dma_bitmode)); in sonic_init()
805 lp->tx_skb[i] = NULL; in sonic_init()
809 (lp->tda_laddr & 0xffff)); in sonic_init()
811 SONIC_WRITE(SONIC_UTDA, lp->tda_laddr >> 16); in sonic_init()
812 SONIC_WRITE(SONIC_CTDA, lp->tda_laddr & 0xffff); in sonic_init()
813 lp->cur_tx = 0; in sonic_init()
814 lp->eol_tx = SONIC_NUM_TDS - 1; in sonic_init()
830 SONIC_WRITE(SONIC_CDP, lp->cda_laddr & 0xffff); in sonic_init()
849 netif_dbg(lp, ifup, dev, "%s: new status=%x\n", __func__, in sonic_init()