• Home
  • Raw
  • Download

Lines Matching refs:sge

256 struct sge {  struct
284 static void tx_sched_stop(struct sge *sge) in tx_sched_stop() argument
286 struct sched *s = sge->tx_sched; in tx_sched_stop()
299 unsigned int t1_sched_update_parms(struct sge *sge, unsigned int port, in t1_sched_update_parms() argument
302 struct sched *s = sge->tx_sched; in t1_sched_update_parms()
322 if (board_info(sge->adapter)->board == CHBT_BOARD_CHT204) { in t1_sched_update_parms()
345 void t1_sched_set_max_avail_bytes(struct sge *sge, unsigned int val)
347 struct sched *s = sge->tx_sched;
352 t1_sched_update_parms(sge, i, 0, 0);
359 void t1_sched_set_drain_bits_per_us(struct sge *sge, unsigned int port,
362 struct sched *s = sge->tx_sched;
365 t1_sched_update_parms(sge, port, 0, 0);
373 static int tx_sched_init(struct sge *sge) in tx_sched_init() argument
383 tasklet_init(&s->sched_tsk, restart_sched, (unsigned long) sge); in tx_sched_init()
384 sge->tx_sched = s; in tx_sched_init()
388 t1_sched_update_parms(sge, i, 1500, 1000); in tx_sched_init()
399 static inline int sched_update_avail(struct sge *sge) in sched_update_avail() argument
401 struct sched *s = sge->tx_sched; in sched_update_avail()
433 static struct sk_buff *sched_skb(struct sge *sge, struct sk_buff *skb, in sched_skb() argument
436 struct sched *s = sge->tx_sched; in sched_skb()
474 if (update-- && sched_update_avail(sge)) in sched_skb()
482 struct cmdQ *q = &sge->cmdQ[0]; in sched_skb()
486 writel(F_CMDQ0_ENABLE, sge->adapter->regs + A_SG_DOORBELL); in sched_skb()
527 static void free_rx_resources(struct sge *sge) in free_rx_resources() argument
529 struct pci_dev *pdev = sge->adapter->pdev; in free_rx_resources()
532 if (sge->respQ.entries) { in free_rx_resources()
533 size = sizeof(struct respQ_e) * sge->respQ.size; in free_rx_resources()
534 pci_free_consistent(pdev, size, sge->respQ.entries, in free_rx_resources()
535 sge->respQ.dma_addr); in free_rx_resources()
539 struct freelQ *q = &sge->freelQ[i]; in free_rx_resources()
557 static int alloc_rx_resources(struct sge *sge, struct sge_params *p) in alloc_rx_resources() argument
559 struct pci_dev *pdev = sge->adapter->pdev; in alloc_rx_resources()
563 struct freelQ *q = &sge->freelQ[i]; in alloc_rx_resources()
567 q->dma_offset = sge->rx_pkt_pad ? 0 : NET_IP_ALIGN; in alloc_rx_resources()
586 sge->freelQ[!sge->jumbo_fl].rx_buffer_size = SGE_RX_SM_BUF_SIZE + in alloc_rx_resources()
588 sge->freelQ[!sge->jumbo_fl].dma_offset; in alloc_rx_resources()
593 sge->freelQ[sge->jumbo_fl].rx_buffer_size = size; in alloc_rx_resources()
599 sge->freelQ[!sge->jumbo_fl].recycleq_idx = 0; in alloc_rx_resources()
600 sge->freelQ[sge->jumbo_fl].recycleq_idx = 1; in alloc_rx_resources()
602 sge->respQ.genbit = 1; in alloc_rx_resources()
603 sge->respQ.size = SGE_RESPQ_E_N; in alloc_rx_resources()
604 sge->respQ.credits = 0; in alloc_rx_resources()
605 size = sizeof(struct respQ_e) * sge->respQ.size; in alloc_rx_resources()
606 sge->respQ.entries = in alloc_rx_resources()
607 pci_alloc_consistent(pdev, size, &sge->respQ.dma_addr); in alloc_rx_resources()
608 if (!sge->respQ.entries) in alloc_rx_resources()
613 free_rx_resources(sge); in alloc_rx_resources()
620 static void free_cmdQ_buffers(struct sge *sge, struct cmdQ *q, unsigned int n) in free_cmdQ_buffers() argument
623 struct pci_dev *pdev = sge->adapter->pdev; in free_cmdQ_buffers()
654 static void free_tx_resources(struct sge *sge) in free_tx_resources() argument
656 struct pci_dev *pdev = sge->adapter->pdev; in free_tx_resources()
660 struct cmdQ *q = &sge->cmdQ[i]; in free_tx_resources()
664 free_cmdQ_buffers(sge, q, q->in_use); in free_tx_resources()
678 static int alloc_tx_resources(struct sge *sge, struct sge_params *p) in alloc_tx_resources() argument
680 struct pci_dev *pdev = sge->adapter->pdev; in alloc_tx_resources()
684 struct cmdQ *q = &sge->cmdQ[i]; in alloc_tx_resources()
712 sge->cmdQ[0].stop_thres = sge->adapter->params.nports * in alloc_tx_resources()
717 free_tx_resources(sge); in alloc_tx_resources()
735 struct sge *sge = adapter->sge; in t1_vlan_mode() local
738 sge->sge_control |= F_VLAN_XTRACT; in t1_vlan_mode()
740 sge->sge_control &= ~F_VLAN_XTRACT; in t1_vlan_mode()
742 writel(sge->sge_control, adapter->regs + A_SG_CONTROL); in t1_vlan_mode()
751 static void configure_sge(struct sge *sge, struct sge_params *p) in configure_sge() argument
753 struct adapter *ap = sge->adapter; in configure_sge()
756 setup_ring_params(ap, sge->cmdQ[0].dma_addr, sge->cmdQ[0].size, in configure_sge()
758 setup_ring_params(ap, sge->cmdQ[1].dma_addr, sge->cmdQ[1].size, in configure_sge()
760 setup_ring_params(ap, sge->freelQ[0].dma_addr, in configure_sge()
761 sge->freelQ[0].size, A_SG_FL0BASELWR, in configure_sge()
763 setup_ring_params(ap, sge->freelQ[1].dma_addr, in configure_sge()
764 sge->freelQ[1].size, A_SG_FL1BASELWR, in configure_sge()
770 setup_ring_params(ap, sge->respQ.dma_addr, sge->respQ.size, in configure_sge()
772 writel((u32)sge->respQ.size - 1, ap->regs + A_SG_RSPQUEUECREDIT); in configure_sge()
774 sge->sge_control = F_CMDQ0_ENABLE | F_CMDQ1_ENABLE | F_FL0_ENABLE | in configure_sge()
777 V_RX_PKT_OFFSET(sge->rx_pkt_pad); in configure_sge()
780 sge->sge_control |= F_ENABLE_BIG_ENDIAN; in configure_sge()
784 sge->intrtimer_nres = SGE_INTRTIMER_NRES * core_ticks_per_usec(ap); in configure_sge()
786 t1_sge_set_coalesce_params(sge, p); in configure_sge()
792 static inline unsigned int jumbo_payload_capacity(const struct sge *sge) in jumbo_payload_capacity() argument
794 return sge->freelQ[sge->jumbo_fl].rx_buffer_size - in jumbo_payload_capacity()
795 sge->freelQ[sge->jumbo_fl].dma_offset - in jumbo_payload_capacity()
802 void t1_sge_destroy(struct sge *sge) in t1_sge_destroy() argument
806 for_each_port(sge->adapter, i) in t1_sge_destroy()
807 free_percpu(sge->port_stats[i]); in t1_sge_destroy()
809 kfree(sge->tx_sched); in t1_sge_destroy()
810 free_tx_resources(sge); in t1_sge_destroy()
811 free_rx_resources(sge); in t1_sge_destroy()
812 kfree(sge); in t1_sge_destroy()
827 static void refill_free_list(struct sge *sge, struct freelQ *q) in refill_free_list() argument
829 struct pci_dev *pdev = sge->adapter->pdev; in refill_free_list()
845 skb_reserve(skb, sge->rx_pkt_pad); in refill_free_list()
873 static void freelQs_empty(struct sge *sge) in freelQs_empty() argument
875 struct adapter *adapter = sge->adapter; in freelQs_empty()
879 refill_free_list(sge, &sge->freelQ[0]); in freelQs_empty()
880 refill_free_list(sge, &sge->freelQ[1]); in freelQs_empty()
882 if (sge->freelQ[0].credits > (sge->freelQ[0].size >> 2) && in freelQs_empty()
883 sge->freelQ[1].credits > (sge->freelQ[1].size >> 2)) { in freelQs_empty()
885 irqholdoff_reg = sge->fixed_intrtimer; in freelQs_empty()
889 irqholdoff_reg = sge->intrtimer_nres; in freelQs_empty()
906 void t1_sge_intr_disable(struct sge *sge) in t1_sge_intr_disable() argument
908 u32 val = readl(sge->adapter->regs + A_PL_ENABLE); in t1_sge_intr_disable()
910 writel(val & ~SGE_PL_INTR_MASK, sge->adapter->regs + A_PL_ENABLE); in t1_sge_intr_disable()
911 writel(0, sge->adapter->regs + A_SG_INT_ENABLE); in t1_sge_intr_disable()
917 void t1_sge_intr_enable(struct sge *sge) in t1_sge_intr_enable() argument
920 u32 val = readl(sge->adapter->regs + A_PL_ENABLE); in t1_sge_intr_enable()
922 if (sge->adapter->port[0].dev->hw_features & NETIF_F_TSO) in t1_sge_intr_enable()
924 writel(en, sge->adapter->regs + A_SG_INT_ENABLE); in t1_sge_intr_enable()
925 writel(val | SGE_PL_INTR_MASK, sge->adapter->regs + A_PL_ENABLE); in t1_sge_intr_enable()
931 void t1_sge_intr_clear(struct sge *sge) in t1_sge_intr_clear() argument
933 writel(SGE_PL_INTR_MASK, sge->adapter->regs + A_PL_CAUSE); in t1_sge_intr_clear()
934 writel(0xffffffff, sge->adapter->regs + A_SG_INT_CAUSE); in t1_sge_intr_clear()
940 int t1_sge_intr_error_handler(struct sge *sge) in t1_sge_intr_error_handler() argument
942 struct adapter *adapter = sge->adapter; in t1_sge_intr_error_handler()
948 sge->stats.respQ_empty++; in t1_sge_intr_error_handler()
950 sge->stats.respQ_overflow++; in t1_sge_intr_error_handler()
955 sge->stats.freelistQ_empty++; in t1_sge_intr_error_handler()
956 freelQs_empty(sge); in t1_sge_intr_error_handler()
959 sge->stats.pkt_too_big++; in t1_sge_intr_error_handler()
964 sge->stats.pkt_mismatch++; in t1_sge_intr_error_handler()
974 const struct sge_intr_counts *t1_sge_get_intr_counts(const struct sge *sge) in t1_sge_get_intr_counts() argument
976 return &sge->stats; in t1_sge_get_intr_counts()
979 void t1_sge_get_port_stats(const struct sge *sge, int port, in t1_sge_get_port_stats() argument
986 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[port], cpu); in t1_sge_get_port_stats()
1290 static inline void reclaim_completed_tx(struct sge *sge, struct cmdQ *q) in reclaim_completed_tx() argument
1297 free_cmdQ_buffers(sge, q, reclaim); in reclaim_completed_tx()
1308 struct sge *sge = (struct sge *) arg; in restart_sched() local
1309 struct adapter *adapter = sge->adapter; in restart_sched()
1310 struct cmdQ *q = &sge->cmdQ[0]; in restart_sched()
1315 reclaim_completed_tx(sge, q); in restart_sched()
1319 while ((skb = sched_skb(sge, NULL, credits)) != NULL) { in restart_sched()
1354 static void sge_rx(struct sge *sge, struct freelQ *fl, unsigned int len) in sge_rx() argument
1358 struct adapter *adapter = sge->adapter; in sge_rx()
1362 skb = get_packet(adapter->pdev, fl, len - sge->rx_pkt_pad); in sge_rx()
1364 sge->stats.rx_drops++; in sge_rx()
1375 st = this_cpu_ptr(sge->port_stats[p->iff]); in sge_rx()
1409 static void restart_tx_queues(struct sge *sge) in restart_tx_queues() argument
1411 struct adapter *adap = sge->adapter; in restart_tx_queues()
1414 if (!enough_free_Tx_descs(&sge->cmdQ[0])) in restart_tx_queues()
1420 if (test_and_clear_bit(nd->if_port, &sge->stopped_tx_queues) && in restart_tx_queues()
1422 sge->stats.cmdQ_restarted[2]++; in restart_tx_queues()
1436 struct sge *sge = adapter->sge; in update_tx_info() local
1437 struct cmdQ *cmdq = &sge->cmdQ[0]; in update_tx_info()
1441 freelQs_empty(sge); in update_tx_info()
1452 if (sge->tx_sched) in update_tx_info()
1453 tasklet_hi_schedule(&sge->tx_sched->sched_tsk); in update_tx_info()
1458 if (unlikely(sge->stopped_tx_queues != 0)) in update_tx_info()
1459 restart_tx_queues(sge); in update_tx_info()
1470 struct sge *sge = adapter->sge; in process_responses() local
1471 struct respQ *q = &sge->respQ; in process_responses()
1493 sge->cmdQ[1].processed += cmdq_processed[1]; in process_responses()
1498 struct freelQ *fl = &sge->freelQ[e->FreelistQid]; in process_responses()
1504 sge_rx(sge, fl, e->BufferLength); in process_responses()
1518 refill_free_list(sge, fl); in process_responses()
1520 sge->stats.pure_rsps++; in process_responses()
1537 sge->cmdQ[1].processed += cmdq_processed[1]; in process_responses()
1544 const struct respQ *Q = &adapter->sge->respQ; in responses_pending()
1560 struct sge *sge = adapter->sge; in process_pure_responses() local
1561 struct respQ *q = &sge->respQ; in process_pure_responses()
1563 const struct freelQ *fl = &sge->freelQ[e->FreelistQid]; in process_pure_responses()
1589 sge->stats.pure_rsps++; in process_pure_responses()
1593 sge->cmdQ[1].processed += cmdq_processed[1]; in process_pure_responses()
1610 writel(adapter->sge->respQ.cidx, in t1_poll()
1619 struct sge *sge = adapter->sge; in t1_interrupt() local
1630 writel(sge->respQ.cidx, adapter->regs + A_SG_SLEEPING); in t1_interrupt()
1643 sge->stats.unhandled_irqs++; in t1_interrupt()
1664 struct sge *sge = adapter->sge; in t1_sge_tx() local
1665 struct cmdQ *q = &sge->cmdQ[qid]; in t1_sge_tx()
1671 reclaim_completed_tx(sge, q); in t1_sge_tx()
1682 set_bit(dev->if_port, &sge->stopped_tx_queues); in t1_sge_tx()
1683 sge->stats.cmdQ_full[2]++; in t1_sge_tx()
1693 set_bit(dev->if_port, &sge->stopped_tx_queues); in t1_sge_tx()
1694 sge->stats.cmdQ_full[2]++; in t1_sge_tx()
1700 if (sge->tx_sched && !qid && skb->dev) { in t1_sge_tx()
1706 skb = sched_skb(sge, skb, credits); in t1_sge_tx()
1776 struct sge *sge = adapter->sge; in t1_start_xmit() local
1777 struct sge_port_stats *st = this_cpu_ptr(sge->port_stats[dev->if_port]); in t1_start_xmit()
1842 if ((unlikely(!adapter->sge->espibug_skb[dev->if_port]))) { in t1_start_xmit()
1845 adapter->sge->espibug_skb[dev->if_port] = skb; in t1_start_xmit()
1890 struct sge *sge = (struct sge *)data; in sge_tx_reclaim_cb() local
1893 struct cmdQ *q = &sge->cmdQ[i]; in sge_tx_reclaim_cb()
1898 reclaim_completed_tx(sge, q); in sge_tx_reclaim_cb()
1900 writel(F_CMDQ0_ENABLE, sge->adapter->regs + A_SG_DOORBELL); in sge_tx_reclaim_cb()
1904 mod_timer(&sge->tx_reclaim_timer, jiffies + TX_RECLAIM_PERIOD); in sge_tx_reclaim_cb()
1910 int t1_sge_set_coalesce_params(struct sge *sge, struct sge_params *p) in t1_sge_set_coalesce_params() argument
1912 sge->fixed_intrtimer = p->rx_coalesce_usecs * in t1_sge_set_coalesce_params()
1913 core_ticks_per_usec(sge->adapter); in t1_sge_set_coalesce_params()
1914 writel(sge->fixed_intrtimer, sge->adapter->regs + A_SG_INTRTIMER); in t1_sge_set_coalesce_params()
1922 int t1_sge_configure(struct sge *sge, struct sge_params *p) in t1_sge_configure() argument
1924 if (alloc_rx_resources(sge, p)) in t1_sge_configure()
1926 if (alloc_tx_resources(sge, p)) { in t1_sge_configure()
1927 free_rx_resources(sge); in t1_sge_configure()
1930 configure_sge(sge, p); in t1_sge_configure()
1938 p->large_buf_capacity = jumbo_payload_capacity(sge); in t1_sge_configure()
1945 void t1_sge_stop(struct sge *sge) in t1_sge_stop() argument
1948 writel(0, sge->adapter->regs + A_SG_CONTROL); in t1_sge_stop()
1949 readl(sge->adapter->regs + A_SG_CONTROL); /* flush */ in t1_sge_stop()
1951 if (is_T2(sge->adapter)) in t1_sge_stop()
1952 del_timer_sync(&sge->espibug_timer); in t1_sge_stop()
1954 del_timer_sync(&sge->tx_reclaim_timer); in t1_sge_stop()
1955 if (sge->tx_sched) in t1_sge_stop()
1956 tx_sched_stop(sge); in t1_sge_stop()
1959 kfree_skb(sge->espibug_skb[i]); in t1_sge_stop()
1965 void t1_sge_start(struct sge *sge) in t1_sge_start() argument
1967 refill_free_list(sge, &sge->freelQ[0]); in t1_sge_start()
1968 refill_free_list(sge, &sge->freelQ[1]); in t1_sge_start()
1970 writel(sge->sge_control, sge->adapter->regs + A_SG_CONTROL); in t1_sge_start()
1971 doorbell_pio(sge->adapter, F_FL0_ENABLE | F_FL1_ENABLE); in t1_sge_start()
1972 readl(sge->adapter->regs + A_SG_CONTROL); /* flush */ in t1_sge_start()
1974 mod_timer(&sge->tx_reclaim_timer, jiffies + TX_RECLAIM_PERIOD); in t1_sge_start()
1976 if (is_T2(sge->adapter)) in t1_sge_start()
1977 mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout); in t1_sge_start()
1986 struct sge *sge = adapter->sge; in espibug_workaround_t204() local
1997 struct sk_buff *skb = sge->espibug_skb[i]; in espibug_workaround_t204()
2023 mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout); in espibug_workaround_t204()
2029 struct sge *sge = adapter->sge; in espibug_workaround() local
2032 struct sk_buff *skb = sge->espibug_skb[0]; in espibug_workaround()
2055 mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout); in espibug_workaround()
2061 struct sge *t1_sge_create(struct adapter *adapter, struct sge_params *p) in t1_sge_create()
2063 struct sge *sge = kzalloc(sizeof(*sge), GFP_KERNEL); in t1_sge_create() local
2066 if (!sge) in t1_sge_create()
2069 sge->adapter = adapter; in t1_sge_create()
2070 sge->netdev = adapter->port[0].dev; in t1_sge_create()
2071 sge->rx_pkt_pad = t1_is_T1B(adapter) ? 0 : 2; in t1_sge_create()
2072 sge->jumbo_fl = t1_is_T1B(adapter) ? 1 : 0; in t1_sge_create()
2075 sge->port_stats[i] = alloc_percpu(struct sge_port_stats); in t1_sge_create()
2076 if (!sge->port_stats[i]) in t1_sge_create()
2080 init_timer(&sge->tx_reclaim_timer); in t1_sge_create()
2081 sge->tx_reclaim_timer.data = (unsigned long)sge; in t1_sge_create()
2082 sge->tx_reclaim_timer.function = sge_tx_reclaim_cb; in t1_sge_create()
2084 if (is_T2(sge->adapter)) { in t1_sge_create()
2085 init_timer(&sge->espibug_timer); in t1_sge_create()
2088 tx_sched_init(sge); in t1_sge_create()
2089 sge->espibug_timer.function = espibug_workaround_t204; in t1_sge_create()
2091 sge->espibug_timer.function = espibug_workaround; in t1_sge_create()
2092 sge->espibug_timer.data = (unsigned long)sge->adapter; in t1_sge_create()
2094 sge->espibug_timeout = 1; in t1_sge_create()
2097 sge->espibug_timeout = HZ/100; in t1_sge_create()
2103 p->freelQ_size[!sge->jumbo_fl] = SGE_FREEL_SIZE; in t1_sge_create()
2104 p->freelQ_size[sge->jumbo_fl] = SGE_JUMBO_FREEL_SIZE; in t1_sge_create()
2105 if (sge->tx_sched) { in t1_sge_create()
2106 if (board_info(sge->adapter)->board == CHBT_BOARD_CHT204) in t1_sge_create()
2116 return sge; in t1_sge_create()
2119 free_percpu(sge->port_stats[i]); in t1_sge_create()
2122 kfree(sge); in t1_sge_create()