Lines Matching +full:4 +full:- +full:ring

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2014-2015 Hisilicon Limited.
31 *hns_rcb_wait_fbd_clean - clean fbd
32 *@qs: ring struct pointer array
57 dev_err(qs[i]->handle->owner_dev, in hns_rcb_wait_fbd_clean()
66 tail = dsaf_read_dev(&qs->tx_ring, RCB_REG_TAIL); in hns_rcb_wait_tx_ring_clean()
69 head = dsaf_read_dev(&qs->tx_ring, RCB_REG_HEAD); in hns_rcb_wait_tx_ring_clean()
77 dev_err(qs->dev->dev, "rcb wait timeout, head not equal to tail.\n"); in hns_rcb_wait_tx_ring_clean()
78 return -EBUSY; in hns_rcb_wait_tx_ring_clean()
85 *hns_rcb_reset_ring_hw - ring reset
86 *@q: ring struct pointer
128 dev_err(q->dev->dev, "port%d reset ring fail\n", in hns_rcb_reset_ring_hw()
129 hns_ae_get_vf_cb(q->handle)->port_index); in hns_rcb_reset_ring_hw()
133 *hns_rcb_int_ctrl_hw - rcb irq enable control
135 *@flag:ring flag tx or rx
189 *hns_rcb_ring_enable_hw - enable ring
190 *@q: rcb ring
204 *hns_rcb_common_init_commit_hw - make rcb common init completed
214 /* hns_rcb_set_tx_ring_bs - init rcb ring buf size regester
226 /* hns_rcb_set_rx_ring_bs - init rcb ring buf size regester
239 *hns_rcb_ring_init - init rcb ring
240 *@ring_pair: ring pair control block
241 *@ring_type: ring type, RX_RING or TX_RING
245 struct hnae_queue *q = &ring_pair->q; in hns_rcb_ring_init()
246 struct hnae_ring *ring = in hns_rcb_ring_init() local
247 (ring_type == RX_RING) ? &q->rx_ring : &q->tx_ring; in hns_rcb_ring_init()
248 dma_addr_t dma = ring->desc_dma_addr; in hns_rcb_ring_init()
256 hns_rcb_set_rx_ring_bs(q, ring->buf_size); in hns_rcb_ring_init()
259 ring_pair->port_id_in_comm); in hns_rcb_ring_init()
261 ring_pair->port_id_in_comm); in hns_rcb_ring_init()
268 hns_rcb_set_tx_ring_bs(q, ring->buf_size); in hns_rcb_ring_init()
271 ring_pair->port_id_in_comm); in hns_rcb_ring_init()
273 ring_pair->port_id_in_comm + HNS_RCB_TX_PKTLINE_OFFSET); in hns_rcb_ring_init()
278 *hns_rcb_init_hw - init rcb hardware
279 *@ring: rcb ring
281 void hns_rcb_init_hw(struct ring_pair_cb *ring) in hns_rcb_init_hw() argument
283 hns_rcb_ring_init(ring, RX_RING); in hns_rcb_init_hw()
284 hns_rcb_ring_init(ring, TX_RING); in hns_rcb_init_hw()
288 *hns_rcb_set_port_desc_cnt - set rcb port description num
296 dsaf_write_dev(rcb_common, RCB_CFG_BD_NUM_REG + port_idx * 4, in hns_rcb_set_port_desc_cnt()
303 if (AE_IS_VER1(rcb_common->dsaf_dev->dsaf_ver)) { in hns_rcb_set_port_timeout()
306 } else if (!HNS_DSAF_IS_DEBUG(rcb_common->dsaf_dev)) { in hns_rcb_set_port_timeout()
309 RCB_PORT_INT_GAPTIME_REG + port_idx * 4, in hns_rcb_set_port_timeout()
313 RCB_PORT_INT_GAPTIME_REG + port_idx * 4, in hns_rcb_set_port_timeout()
317 RCB_PORT_CFG_OVERTIME_REG + port_idx * 4, in hns_rcb_set_port_timeout()
321 RCB_PORT_CFG_OVERTIME_REG + port_idx * 4, in hns_rcb_set_port_timeout()
328 if (!HNS_DSAF_IS_DEBUG(rcb_common->dsaf_dev)) in hns_rcb_common_get_port_num()
364 *hns_rcb_common_init_hw - init rcb common hardware
366 *retuen 0 - success , negative --fail
378 dev_err(rcb_common->dsaf_dev->dev, in hns_rcb_common_init_hw()
380 return -EBUSY; in hns_rcb_common_init_hw()
384 hns_rcb_set_port_desc_cnt(rcb_common, i, rcb_common->desc_num); in hns_rcb_common_init_hw()
387 if (!AE_IS_VER1(rcb_common->dsaf_dev->dsaf_ver) && in hns_rcb_common_init_hw()
388 !HNS_DSAF_IS_DEBUG(rcb_common->dsaf_dev)) in hns_rcb_common_init_hw()
398 if (AE_IS_VER1(rcb_common->dsaf_dev->dsaf_ver)) { in hns_rcb_common_init_hw()
431 bd_size_type = -EINVAL; in hns_rcb_buf_size2type()
439 struct hnae_ring *ring; in hns_rcb_ring_get_cfg() local
446 is_ver1 = AE_IS_VER1(ring_pair_cb->rcb_common->dsaf_dev->dsaf_ver); in hns_rcb_ring_get_cfg()
448 ring = &q->rx_ring; in hns_rcb_ring_get_cfg()
449 ring->io_base = ring_pair_cb->q.io_base; in hns_rcb_ring_get_cfg()
453 ring = &q->tx_ring; in hns_rcb_ring_get_cfg()
454 ring->io_base = ring_pair_cb->q.io_base + in hns_rcb_ring_get_cfg()
461 rcb_common = ring_pair_cb->rcb_common; in hns_rcb_ring_get_cfg()
462 desc_num = rcb_common->dsaf_dev->desc_num; in hns_rcb_ring_get_cfg()
464 ring->desc = NULL; in hns_rcb_ring_get_cfg()
465 ring->desc_cb = NULL; in hns_rcb_ring_get_cfg()
467 ring->irq = ring_pair_cb->virq[irq_idx]; in hns_rcb_ring_get_cfg()
468 ring->desc_dma_addr = 0; in hns_rcb_ring_get_cfg()
470 ring->buf_size = RCB_DEFAULT_BUFFER_SIZE; in hns_rcb_ring_get_cfg()
471 ring->desc_num = desc_num; in hns_rcb_ring_get_cfg()
472 ring->max_desc_num_per_pkt = mdnum_ppkt; in hns_rcb_ring_get_cfg()
473 ring->max_raw_data_sz_per_desc = HNS_RCB_MAX_PKT_SIZE; in hns_rcb_ring_get_cfg()
474 ring->max_pkt_size = HNS_RCB_MAX_PKT_SIZE; in hns_rcb_ring_get_cfg()
475 ring->next_to_use = 0; in hns_rcb_ring_get_cfg()
476 ring->next_to_clean = 0; in hns_rcb_ring_get_cfg()
481 ring_pair_cb->q.handle = NULL; in hns_rcb_ring_pair_get_cfg()
483 hns_rcb_ring_get_cfg(&ring_pair_cb->q, RX_RING); in hns_rcb_ring_pair_get_cfg()
484 hns_rcb_ring_get_cfg(&ring_pair_cb->q, TX_RING); in hns_rcb_ring_pair_get_cfg()
490 return ring_idx / (rcb_common->max_q_per_vf * rcb_common->max_vfn); in hns_rcb_get_port_in_comm()
497 bool is_ver1 = AE_IS_VER1(rcb_common->dsaf_dev->dsaf_ver); in hns_rcb_get_base_irq_idx()
499 if (!HNS_DSAF_IS_DEBUG(rcb_common->dsaf_dev)) in hns_rcb_get_base_irq_idx()
508 *hns_rcb_get_cfg - get rcb config
515 u32 ring_num = rcb_common->ring_num; in hns_rcb_get_cfg()
518 to_platform_device(rcb_common->dsaf_dev->dev); in hns_rcb_get_cfg()
519 bool is_ver1 = AE_IS_VER1(rcb_common->dsaf_dev->dsaf_ver); in hns_rcb_get_cfg()
522 ring_pair_cb = &rcb_common->ring_pair_cb[i]; in hns_rcb_get_cfg()
523 ring_pair_cb->rcb_common = rcb_common; in hns_rcb_get_cfg()
524 ring_pair_cb->dev = rcb_common->dsaf_dev->dev; in hns_rcb_get_cfg()
525 ring_pair_cb->index = i; in hns_rcb_get_cfg()
526 ring_pair_cb->q.io_base = in hns_rcb_get_cfg()
527 RCB_COMM_BASE_TO_RING_BASE(rcb_common->io_base, i); in hns_rcb_get_cfg()
528 ring_pair_cb->port_id_in_comm = in hns_rcb_get_cfg()
530 ring_pair_cb->virq[HNS_RCB_IRQ_IDX_TX] = in hns_rcb_get_cfg()
533 ring_pair_cb->virq[HNS_RCB_IRQ_IDX_RX] = in hns_rcb_get_cfg()
536 if ((ring_pair_cb->virq[HNS_RCB_IRQ_IDX_TX] == -EPROBE_DEFER) || in hns_rcb_get_cfg()
537 (ring_pair_cb->virq[HNS_RCB_IRQ_IDX_RX] == -EPROBE_DEFER)) in hns_rcb_get_cfg()
538 return -EPROBE_DEFER; in hns_rcb_get_cfg()
540 ring_pair_cb->q.phy_base = in hns_rcb_get_cfg()
541 RCB_COMM_BASE_TO_RING_BASE(rcb_common->phy_base, i); in hns_rcb_get_cfg()
549 *hns_rcb_get_rx_coalesced_frames - get rcb port rx coalesced frames
558 return dsaf_read_dev(rcb_common, RCB_CFG_PKTLINE_REG + port_idx * 4); in hns_rcb_get_rx_coalesced_frames()
562 *hns_rcb_get_tx_coalesced_frames - get rcb port tx coalesced frames
573 reg = RCB_CFG_PKTLINE_REG + (port_idx + HNS_RCB_TX_PKTLINE_OFFSET) * 4; in hns_rcb_get_tx_coalesced_frames()
578 *hns_rcb_get_coalesce_usecs - get rcb port coalesced time_out
587 if (AE_IS_VER1(rcb_common->dsaf_dev->dsaf_ver)) in hns_rcb_get_coalesce_usecs()
592 RCB_PORT_CFG_OVERTIME_REG + port_idx * 4); in hns_rcb_get_coalesce_usecs()
596 *hns_rcb_set_coalesce_usecs - set rcb port coalesced time_out
612 if (AE_IS_VER1(rcb_common->dsaf_dev->dsaf_ver)) { in hns_rcb_set_coalesce_usecs()
613 if (!HNS_DSAF_IS_DEBUG(rcb_common->dsaf_dev)) { in hns_rcb_set_coalesce_usecs()
614 dev_err(rcb_common->dsaf_dev->dev, in hns_rcb_set_coalesce_usecs()
616 return -EINVAL; in hns_rcb_set_coalesce_usecs()
620 dev_err(rcb_common->dsaf_dev->dev, in hns_rcb_set_coalesce_usecs()
622 return -EINVAL; in hns_rcb_set_coalesce_usecs()
629 *hns_rcb_set_tx_coalesced_frames - set rcb coalesced frames
648 dev_err(rcb_common->dsaf_dev->dev, in hns_rcb_set_tx_coalesced_frames()
650 return -EINVAL; in hns_rcb_set_tx_coalesced_frames()
653 reg = RCB_CFG_PKTLINE_REG + (port_idx + HNS_RCB_TX_PKTLINE_OFFSET) * 4; in hns_rcb_set_tx_coalesced_frames()
659 *hns_rcb_set_rx_coalesced_frames - set rcb rx coalesced frames
676 if (coalesced_frames >= rcb_common->desc_num || in hns_rcb_set_rx_coalesced_frames()
679 dev_err(rcb_common->dsaf_dev->dev, in hns_rcb_set_rx_coalesced_frames()
681 return -EINVAL; in hns_rcb_set_rx_coalesced_frames()
684 dsaf_write_dev(rcb_common, RCB_CFG_PKTLINE_REG + port_idx * 4, in hns_rcb_set_rx_coalesced_frames()
690 *hns_rcb_get_queue_mode - get max VM number and max ring number per VM
694 *@max_q_per_vf:max ring number per vm
726 switch (dsaf_dev->dsaf_mode) { in hns_rcb_get_ring_num()
753 dev_warn(dsaf_dev->dev, in hns_rcb_get_ring_num()
754 "get ring num fail,use default!dsaf_mode=%d\n", in hns_rcb_get_ring_num()
755 dsaf_dev->dsaf_mode); in hns_rcb_get_ring_num()
762 struct dsaf_device *dsaf_dev = rcb_common->dsaf_dev; in hns_rcb_common_get_vaddr()
764 return dsaf_dev->ppe_base + RCB_COMMON_REG_OFFSET; in hns_rcb_common_get_vaddr()
769 struct dsaf_device *dsaf_dev = rcb_common->dsaf_dev; in hns_rcb_common_get_paddr()
771 return dsaf_dev->ppe_paddr + RCB_COMMON_REG_OFFSET; in hns_rcb_common_get_paddr()
778 enum dsaf_mode dsaf_mode = dsaf_dev->dsaf_mode; in hns_rcb_common_get_cfg()
784 devm_kzalloc(dsaf_dev->dev, in hns_rcb_common_get_cfg()
788 dev_err(dsaf_dev->dev, "rcb common devm_kzalloc fail!\n"); in hns_rcb_common_get_cfg()
789 return -ENOMEM; in hns_rcb_common_get_cfg()
791 rcb_common->comm_index = comm_index; in hns_rcb_common_get_cfg()
792 rcb_common->ring_num = ring_num; in hns_rcb_common_get_cfg()
793 rcb_common->dsaf_dev = dsaf_dev; in hns_rcb_common_get_cfg()
795 rcb_common->desc_num = dsaf_dev->desc_num; in hns_rcb_common_get_cfg()
798 rcb_common->max_vfn = max_vfn; in hns_rcb_common_get_cfg()
799 rcb_common->max_q_per_vf = max_q_per_vf; in hns_rcb_common_get_cfg()
801 rcb_common->io_base = hns_rcb_common_get_vaddr(rcb_common); in hns_rcb_common_get_cfg()
802 rcb_common->phy_base = hns_rcb_common_get_paddr(rcb_common); in hns_rcb_common_get_cfg()
804 dsaf_dev->rcb_common[comm_index] = rcb_common; in hns_rcb_common_get_cfg()
811 dsaf_dev->rcb_common[comm_index] = NULL; in hns_rcb_common_free_cfg()
816 struct ring_pair_cb *ring = in hns_rcb_update_stats() local
818 struct dsaf_device *dsaf_dev = ring->rcb_common->dsaf_dev; in hns_rcb_update_stats()
820 = dsaf_dev->ppe_common[ring->rcb_common->comm_index]; in hns_rcb_update_stats()
821 struct hns_ring_hw_stats *hw_stats = &ring->hw_stats; in hns_rcb_update_stats()
823 hw_stats->rx_pkts += dsaf_read_dev(queue, in hns_rcb_update_stats()
827 hw_stats->ppe_rx_ok_pkts += dsaf_read_dev(ppe_common, in hns_rcb_update_stats()
828 PPE_COM_HIS_RX_PKT_QID_OK_CNT_REG + 4 * ring->index); in hns_rcb_update_stats()
829 hw_stats->ppe_rx_drop_pkts += dsaf_read_dev(ppe_common, in hns_rcb_update_stats()
830 PPE_COM_HIS_RX_PKT_QID_DROP_CNT_REG + 4 * ring->index); in hns_rcb_update_stats()
832 hw_stats->tx_pkts += dsaf_read_dev(queue, in hns_rcb_update_stats()
836 hw_stats->ppe_tx_ok_pkts += dsaf_read_dev(ppe_common, in hns_rcb_update_stats()
837 PPE_COM_HIS_TX_PKT_QID_OK_CNT_REG + 4 * ring->index); in hns_rcb_update_stats()
838 hw_stats->ppe_tx_drop_pkts += dsaf_read_dev(ppe_common, in hns_rcb_update_stats()
839 PPE_COM_HIS_TX_PKT_QID_ERR_CNT_REG + 4 * ring->index); in hns_rcb_update_stats()
843 *hns_rcb_get_stats - get rcb statistic
844 *@queue: rcb ring
850 struct ring_pair_cb *ring = in hns_rcb_get_stats() local
852 struct hns_ring_hw_stats *hw_stats = &ring->hw_stats; in hns_rcb_get_stats()
854 regs_buff[0] = hw_stats->tx_pkts; in hns_rcb_get_stats()
855 regs_buff[1] = hw_stats->ppe_tx_ok_pkts; in hns_rcb_get_stats()
856 regs_buff[2] = hw_stats->ppe_tx_drop_pkts; in hns_rcb_get_stats()
860 regs_buff[4] = queue->tx_ring.stats.tx_pkts; in hns_rcb_get_stats()
861 regs_buff[5] = queue->tx_ring.stats.tx_bytes; in hns_rcb_get_stats()
862 regs_buff[6] = queue->tx_ring.stats.tx_err_cnt; in hns_rcb_get_stats()
863 regs_buff[7] = queue->tx_ring.stats.io_err_cnt; in hns_rcb_get_stats()
864 regs_buff[8] = queue->tx_ring.stats.sw_err_cnt; in hns_rcb_get_stats()
865 regs_buff[9] = queue->tx_ring.stats.seg_pkt_cnt; in hns_rcb_get_stats()
866 regs_buff[10] = queue->tx_ring.stats.restart_queue; in hns_rcb_get_stats()
867 regs_buff[11] = queue->tx_ring.stats.tx_busy; in hns_rcb_get_stats()
869 regs_buff[12] = hw_stats->rx_pkts; in hns_rcb_get_stats()
870 regs_buff[13] = hw_stats->ppe_rx_ok_pkts; in hns_rcb_get_stats()
871 regs_buff[14] = hw_stats->ppe_rx_drop_pkts; in hns_rcb_get_stats()
875 regs_buff[16] = queue->rx_ring.stats.rx_pkts; in hns_rcb_get_stats()
876 regs_buff[17] = queue->rx_ring.stats.rx_bytes; in hns_rcb_get_stats()
877 regs_buff[18] = queue->rx_ring.stats.rx_err_cnt; in hns_rcb_get_stats()
878 regs_buff[19] = queue->rx_ring.stats.io_err_cnt; in hns_rcb_get_stats()
879 regs_buff[20] = queue->rx_ring.stats.sw_err_cnt; in hns_rcb_get_stats()
880 regs_buff[21] = queue->rx_ring.stats.seg_pkt_cnt; in hns_rcb_get_stats()
881 regs_buff[22] = queue->rx_ring.stats.reuse_pg_cnt; in hns_rcb_get_stats()
882 regs_buff[23] = queue->rx_ring.stats.err_pkt_len; in hns_rcb_get_stats()
883 regs_buff[24] = queue->rx_ring.stats.non_vld_descs; in hns_rcb_get_stats()
884 regs_buff[25] = queue->rx_ring.stats.err_bd_num; in hns_rcb_get_stats()
885 regs_buff[26] = queue->rx_ring.stats.l2_err; in hns_rcb_get_stats()
886 regs_buff[27] = queue->rx_ring.stats.l3l4_csum_err; in hns_rcb_get_stats()
890 *hns_rcb_get_ring_sset_count - rcb string set count
892 *return rcb ring string set count
903 *hns_rcb_get_common_regs_count - rcb common regs count
912 *hns_rcb_get_ring_regs_count - rcb ring regs count
921 *hns_rcb_get_strings - get rcb string set
969 bool is_ver1 = AE_IS_VER1(rcb_com->dsaf_dev->dsaf_ver); in hns_rcb_get_common_regs()
970 bool is_dbg = HNS_DSAF_IS_DEBUG(rcb_com->dsaf_dev); in hns_rcb_get_common_regs()
981 regs[4] = dsaf_read_dev(rcb_com, RCB_COM_CFG_RINVLD_REG); in hns_rcb_get_common_regs()
1021 = dsaf_read_dev(rcb_com, RCB_CFG_BD_NUM_REG + 4 * i); in hns_rcb_get_common_regs()
1023 = dsaf_read_dev(rcb_com, RCB_CFG_PKTLINE_REG + 4 * i); in hns_rcb_get_common_regs()
1046 /*rcb ring registers */ in hns_rcb_get_ring_regs()
1051 regs[4] = dsaf_read_dev(queue, RCB_RING_RX_RING_PKTLINE_REG); in hns_rcb_get_ring_regs()
1085 /* mark end of ring regs */ in hns_rcb_get_ring_regs()
1087 regs[i] = 0xcccccc00 + ring_pair->index; in hns_rcb_get_ring_regs()