Lines Matching +full:wait +full:- +full:queue

1 // SPDX-License-Identifier: GPL-2.0
11 * __ice_vsi_get_qs_contig - Assign a contiguous chunk of queues to VSI
12 * @qs_cfg: gathered variables needed for PF->VSI queues assignment
14 * Return 0 on success and -ENOMEM in case of no left space in PF queue bitmap
20 mutex_lock(qs_cfg->qs_mutex); in __ice_vsi_get_qs_contig()
21 offset = bitmap_find_next_zero_area(qs_cfg->pf_map, qs_cfg->pf_map_size, in __ice_vsi_get_qs_contig()
22 0, qs_cfg->q_count, 0); in __ice_vsi_get_qs_contig()
23 if (offset >= qs_cfg->pf_map_size) { in __ice_vsi_get_qs_contig()
24 mutex_unlock(qs_cfg->qs_mutex); in __ice_vsi_get_qs_contig()
25 return -ENOMEM; in __ice_vsi_get_qs_contig()
28 bitmap_set(qs_cfg->pf_map, offset, qs_cfg->q_count); in __ice_vsi_get_qs_contig()
29 for (i = 0; i < qs_cfg->q_count; i++) in __ice_vsi_get_qs_contig()
30 qs_cfg->vsi_map[i + qs_cfg->vsi_map_offset] = (u16)(i + offset); in __ice_vsi_get_qs_contig()
31 mutex_unlock(qs_cfg->qs_mutex); in __ice_vsi_get_qs_contig()
37 * __ice_vsi_get_qs_sc - Assign a scattered queues from PF to VSI
38 * @qs_cfg: gathered variables needed for pf->vsi queues assignment
40 * Return 0 on success and -ENOMEM in case of no left space in PF queue bitmap
46 mutex_lock(qs_cfg->qs_mutex); in __ice_vsi_get_qs_sc()
47 for (i = 0; i < qs_cfg->q_count; i++) { in __ice_vsi_get_qs_sc()
48 index = find_next_zero_bit(qs_cfg->pf_map, in __ice_vsi_get_qs_sc()
49 qs_cfg->pf_map_size, index); in __ice_vsi_get_qs_sc()
50 if (index >= qs_cfg->pf_map_size) in __ice_vsi_get_qs_sc()
52 set_bit(index, qs_cfg->pf_map); in __ice_vsi_get_qs_sc()
53 qs_cfg->vsi_map[i + qs_cfg->vsi_map_offset] = (u16)index; in __ice_vsi_get_qs_sc()
55 mutex_unlock(qs_cfg->qs_mutex); in __ice_vsi_get_qs_sc()
60 clear_bit(qs_cfg->vsi_map[index], qs_cfg->pf_map); in __ice_vsi_get_qs_sc()
61 qs_cfg->vsi_map[index + qs_cfg->vsi_map_offset] = 0; in __ice_vsi_get_qs_sc()
63 mutex_unlock(qs_cfg->qs_mutex); in __ice_vsi_get_qs_sc()
65 return -ENOMEM; in __ice_vsi_get_qs_sc()
69 * ice_pf_rxq_wait - Wait for a PF's Rx queue to be enabled or disabled
71 * @pf_q: the PF queue
72 * @ena: enable or disable state of the queue
74 * This routine will wait for the given Rx queue of the PF to reach the
76 * Returns -ETIMEDOUT in case of failing to reach the requested state after
84 if (ena == !!(rd32(&pf->hw, QRX_CTRL(pf_q)) & in ice_pf_rxq_wait()
91 return -ETIMEDOUT; in ice_pf_rxq_wait()
95 * ice_vsi_alloc_q_vector - Allocate memory for a single interrupt vector
100 * with this q_vector. If allocation fails we return -ENOMEM.
104 struct ice_pf *pf = vsi->back; in ice_vsi_alloc_q_vector()
111 return -ENOMEM; in ice_vsi_alloc_q_vector()
113 q_vector->vsi = vsi; in ice_vsi_alloc_q_vector()
114 q_vector->v_idx = v_idx; in ice_vsi_alloc_q_vector()
115 q_vector->tx.itr_setting = ICE_DFLT_TX_ITR; in ice_vsi_alloc_q_vector()
116 q_vector->rx.itr_setting = ICE_DFLT_RX_ITR; in ice_vsi_alloc_q_vector()
117 q_vector->tx.itr_mode = ITR_DYNAMIC; in ice_vsi_alloc_q_vector()
118 q_vector->rx.itr_mode = ITR_DYNAMIC; in ice_vsi_alloc_q_vector()
119 q_vector->tx.type = ICE_TX_CONTAINER; in ice_vsi_alloc_q_vector()
120 q_vector->rx.type = ICE_RX_CONTAINER; in ice_vsi_alloc_q_vector()
121 q_vector->irq.index = -ENOENT; in ice_vsi_alloc_q_vector()
123 if (vsi->type == ICE_VSI_VF) { in ice_vsi_alloc_q_vector()
124 ice_calc_vf_reg_idx(vsi->vf, q_vector); in ice_vsi_alloc_q_vector()
126 } else if (vsi->type == ICE_VSI_CTRL && vsi->vf) { in ice_vsi_alloc_q_vector()
130 if (unlikely(!ctrl_vsi->q_vectors)) { in ice_vsi_alloc_q_vector()
131 err = -ENOENT; in ice_vsi_alloc_q_vector()
135 q_vector->irq = ctrl_vsi->q_vectors[0]->irq; in ice_vsi_alloc_q_vector()
140 q_vector->irq = ice_alloc_irq(pf, vsi->irq_dyn_alloc); in ice_vsi_alloc_q_vector()
141 if (q_vector->irq.index < 0) { in ice_vsi_alloc_q_vector()
142 err = -ENOMEM; in ice_vsi_alloc_q_vector()
147 q_vector->reg_idx = q_vector->irq.index; in ice_vsi_alloc_q_vector()
148 q_vector->vf_reg_idx = q_vector->irq.index; in ice_vsi_alloc_q_vector()
152 cpumask_set_cpu(v_idx, &q_vector->affinity_mask); in ice_vsi_alloc_q_vector()
158 if (vsi->netdev) in ice_vsi_alloc_q_vector()
159 netif_napi_add_config(vsi->netdev, &q_vector->napi, in ice_vsi_alloc_q_vector()
164 vsi->q_vectors[v_idx] = q_vector; in ice_vsi_alloc_q_vector()
175 * ice_free_q_vector - Free memory allocated for a specific interrupt vector
182 struct ice_pf *pf = vsi->back; in ice_free_q_vector()
188 if (!vsi->q_vectors[v_idx]) { in ice_free_q_vector()
189 dev_dbg(dev, "Queue vector at index %d not found\n", v_idx); in ice_free_q_vector()
192 q_vector = vsi->q_vectors[v_idx]; in ice_free_q_vector()
194 ice_for_each_tx_ring(tx_ring, vsi->q_vectors[v_idx]->tx) in ice_free_q_vector()
195 tx_ring->q_vector = NULL; in ice_free_q_vector()
197 ice_for_each_rx_ring(rx_ring, vsi->q_vectors[v_idx]->rx) in ice_free_q_vector()
198 rx_ring->q_vector = NULL; in ice_free_q_vector()
201 if (vsi->netdev) in ice_free_q_vector()
202 netif_napi_del(&q_vector->napi); in ice_free_q_vector()
205 if (q_vector->irq.index < 0) in ice_free_q_vector()
209 if (vsi->type == ICE_VSI_CTRL && vsi->vf && in ice_free_q_vector()
213 ice_free_irq(pf, q_vector->irq); in ice_free_q_vector()
217 vsi->q_vectors[v_idx] = NULL; in ice_free_q_vector()
221 * ice_cfg_itr_gran - set the ITR granularity to 2 usecs if not already set
244 * ice_calc_txq_handle - calculate the queue handle
246 * @ring: ring to get the absolute queue index
253 if (ring->ch) in ice_calc_txq_handle()
254 return ring->q_index - ring->ch->base_q; in ice_calc_txq_handle()
256 /* Idea here for calculation is that we subtract the number of queue in ice_calc_txq_handle()
257 * count from TC that ring belongs to from it's absolute queue index in ice_calc_txq_handle()
258 * and as a result we get the queue's index within TC. in ice_calc_txq_handle()
260 return ring->q_index - vsi->tc_cfg.tc_info[tc].qoffset; in ice_calc_txq_handle()
264 * ice_cfg_xps_tx_ring - Configure XPS for a Tx ring
272 if (!ring->q_vector || !ring->netdev) in ice_cfg_xps_tx_ring()
276 if (test_and_set_bit(ICE_TX_XPS_INIT_DONE, ring->xps_state)) in ice_cfg_xps_tx_ring()
279 netif_set_xps_queue(ring->netdev, &ring->q_vector->affinity_mask, in ice_cfg_xps_tx_ring()
280 ring->q_index); in ice_cfg_xps_tx_ring()
284 * ice_setup_tx_ctx - setup a struct ice_tlan_ctx instance
286 * @tlan_ctx: Pointer to the Tx LAN queue context structure to be initialized
287 * @pf_q: queue index in the PF space
294 struct ice_vsi *vsi = ring->vsi; in ice_setup_tx_ctx()
295 struct ice_hw *hw = &vsi->back->hw; in ice_setup_tx_ctx()
297 tlan_ctx->base = ring->dma >> ICE_TLAN_CTX_BASE_S; in ice_setup_tx_ctx()
299 tlan_ctx->port_num = vsi->port_info->lport; in ice_setup_tx_ctx()
301 /* Transmit Queue Length */ in ice_setup_tx_ctx()
302 tlan_ctx->qlen = ring->count; in ice_setup_tx_ctx()
304 ice_set_cgd_num(tlan_ctx, ring->dcb_tc); in ice_setup_tx_ctx()
307 tlan_ctx->pf_num = hw->pf_id; in ice_setup_tx_ctx()
309 /* queue belongs to a specific VSI type in ice_setup_tx_ctx()
311 * for vmvf_type = VF, it is VF number between 0-256 in ice_setup_tx_ctx()
312 * for vmvf_type = VM, it is VM number between 0-767 in ice_setup_tx_ctx()
315 switch (vsi->type) { in ice_setup_tx_ctx()
319 if (ring->ch) in ice_setup_tx_ctx()
320 tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_VMQ; in ice_setup_tx_ctx()
322 tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_PF; in ice_setup_tx_ctx()
326 tlan_ctx->vmvf_num = hw->func_caps.vf_base_id + vsi->vf->vf_id; in ice_setup_tx_ctx()
327 tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_VF; in ice_setup_tx_ctx()
330 tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_VMQ; in ice_setup_tx_ctx()
337 if (ring->ch) in ice_setup_tx_ctx()
338 tlan_ctx->src_vsi = ring->ch->vsi_num; in ice_setup_tx_ctx()
340 tlan_ctx->src_vsi = ice_get_hw_vsi_num(hw, vsi->idx); in ice_setup_tx_ctx()
343 switch (vsi->type) { in ice_setup_tx_ctx()
345 tlan_ctx->tsyn_ena = 1; in ice_setup_tx_ctx()
351 tlan_ctx->quanta_prof_idx = ring->quanta_prof_id; in ice_setup_tx_ctx()
353 tlan_ctx->tso_ena = ICE_TX_LEGACY; in ice_setup_tx_ctx()
354 tlan_ctx->tso_qnum = pf_q; in ice_setup_tx_ctx()
360 tlan_ctx->legacy_int = ICE_TX_LEGACY; in ice_setup_tx_ctx()
364 * ice_rx_offset - Return expected offset into page to access data
377 * ice_setup_rx_ctx - Configure a receive ring context
384 struct ice_vsi *vsi = ring->vsi; in ice_setup_rx_ctx()
391 hw = &vsi->back->hw; in ice_setup_rx_ctx()
393 /* what is Rx queue number in global space of 2K Rx queues */ in ice_setup_rx_ctx()
394 pf_q = vsi->rxq_map[ring->q_index]; in ice_setup_rx_ctx()
399 /* Receive Queue Base Address. in ice_setup_rx_ctx()
400 * Indicates the starting address of the descriptor queue defined in in ice_setup_rx_ctx()
403 rlan_ctx.base = ring->dma >> ICE_RLAN_BASE_S; in ice_setup_rx_ctx()
405 rlan_ctx.qlen = ring->count; in ice_setup_rx_ctx()
410 rlan_ctx.dbuf = DIV_ROUND_UP(ring->rx_buf_len, in ice_setup_rx_ctx()
419 rlan_ctx.crcstrip = !(ring->flags & ICE_RX_FLAGS_CRC_STRIP_DIS); in ice_setup_rx_ctx()
422 * and it needs to remain 1 for non-DVM capable configurations to not in ice_setup_rx_ctx()
430 if (vsi->type == ICE_VSI_VF && in ice_setup_rx_ctx()
431 ice_vf_is_port_vlan_ena(vsi->vf)) in ice_setup_rx_ctx()
448 /* Max packet size for this queue - must not be set to a larger value in ice_setup_rx_ctx()
451 rlan_ctx.rxmax = min_t(u32, ring->max_frame, in ice_setup_rx_ctx()
452 ICE_MAX_CHAINED_RX_BUFS * ring->rx_buf_len); in ice_setup_rx_ctx()
454 /* Rx queue threshold in units of 64 */ in ice_setup_rx_ctx()
460 if (ice_is_eswitch_mode_switchdev(vsi->back)) { in ice_setup_rx_ctx()
461 ring->flags |= ICE_RX_FLAGS_MULTIDEV; in ice_setup_rx_ctx()
465 /* Enable Flexible Descriptors in the queue context which in ice_setup_rx_ctx()
471 if (vsi->type != ICE_VSI_VF) in ice_setup_rx_ctx()
477 /* Absolute queue number out of 2K needs to be passed */ in ice_setup_rx_ctx()
480 …dev_err(ice_pf_to_dev(vsi->back), "Failed to set LAN Rx queue context for absolute Rx queue %d err… in ice_setup_rx_ctx()
482 return -EIO; in ice_setup_rx_ctx()
485 if (vsi->type == ICE_VSI_VF) in ice_setup_rx_ctx()
489 if (!vsi->netdev || test_bit(ICE_FLAG_LEGACY_RX, vsi->back->flags)) in ice_setup_rx_ctx()
494 ring->rx_offset = ice_rx_offset(ring); in ice_setup_rx_ctx()
496 /* init queue specific tail register */ in ice_setup_rx_ctx()
497 ring->tail = hw->hw_addr + QRX_TAIL(pf_q); in ice_setup_rx_ctx()
498 writel(0, ring->tail); in ice_setup_rx_ctx()
505 void *ctx_ptr = &ring->pkt_ctx; in ice_xsk_pool_fill_cb()
510 desc.off = offsetof(struct ice_xdp_buff, pkt_ctx) - in ice_xsk_pool_fill_cb()
513 xsk_pool_fill_cb(ring->xsk_pool, &desc); in ice_xsk_pool_fill_cb()
517 * ice_get_frame_sz - calculate xdp_buff::frame_sz
527 frame_sz = rx_ring->rx_buf_len; in ice_get_frame_sz()
536 * ice_vsi_cfg_rxq - Configure an Rx queue
543 struct device *dev = ice_pf_to_dev(ring->vsi->back); in ice_vsi_cfg_rxq()
547 if (ring->vsi->type == ICE_VSI_PF || ring->vsi->type == ICE_VSI_SF) { in ice_vsi_cfg_rxq()
548 if (!xdp_rxq_info_is_reg(&ring->xdp_rxq)) { in ice_vsi_cfg_rxq()
549 err = __xdp_rxq_info_reg(&ring->xdp_rxq, ring->netdev, in ice_vsi_cfg_rxq()
550 ring->q_index, in ice_vsi_cfg_rxq()
551 ring->q_vector->napi.napi_id, in ice_vsi_cfg_rxq()
552 ring->rx_buf_len); in ice_vsi_cfg_rxq()
558 if (ring->xsk_pool) { in ice_vsi_cfg_rxq()
559 xdp_rxq_info_unreg(&ring->xdp_rxq); in ice_vsi_cfg_rxq()
561 ring->rx_buf_len = in ice_vsi_cfg_rxq()
562 xsk_pool_get_rx_frame_size(ring->xsk_pool); in ice_vsi_cfg_rxq()
563 err = __xdp_rxq_info_reg(&ring->xdp_rxq, ring->netdev, in ice_vsi_cfg_rxq()
564 ring->q_index, in ice_vsi_cfg_rxq()
565 ring->q_vector->napi.napi_id, in ice_vsi_cfg_rxq()
566 ring->rx_buf_len); in ice_vsi_cfg_rxq()
569 err = xdp_rxq_info_reg_mem_model(&ring->xdp_rxq, in ice_vsi_cfg_rxq()
574 xsk_pool_set_rxq_info(ring->xsk_pool, &ring->xdp_rxq); in ice_vsi_cfg_rxq()
578 ring->q_index); in ice_vsi_cfg_rxq()
580 if (!xdp_rxq_info_is_reg(&ring->xdp_rxq)) { in ice_vsi_cfg_rxq()
581 err = __xdp_rxq_info_reg(&ring->xdp_rxq, ring->netdev, in ice_vsi_cfg_rxq()
582 ring->q_index, in ice_vsi_cfg_rxq()
583 ring->q_vector->napi.napi_id, in ice_vsi_cfg_rxq()
584 ring->rx_buf_len); in ice_vsi_cfg_rxq()
589 err = xdp_rxq_info_reg_mem_model(&ring->xdp_rxq, in ice_vsi_cfg_rxq()
597 xdp_init_buff(&ring->xdp, ice_get_frame_sz(ring), &ring->xdp_rxq); in ice_vsi_cfg_rxq()
598 ring->xdp.data = NULL; in ice_vsi_cfg_rxq()
599 ring->xdp_ext.pkt_ctx = &ring->pkt_ctx; in ice_vsi_cfg_rxq()
603 ring->q_index, err); in ice_vsi_cfg_rxq()
607 if (ring->xsk_pool) { in ice_vsi_cfg_rxq()
610 if (!xsk_buff_can_alloc(ring->xsk_pool, num_bufs)) { in ice_vsi_cfg_rxq()
612 num_bufs, ring->q_index); in ice_vsi_cfg_rxq()
613 dev_warn(dev, "Change Rx ring/fill queue size to avoid performance issues\n"); in ice_vsi_cfg_rxq()
618 ok = ice_alloc_rx_bufs_zc(ring, ring->xsk_pool, num_bufs); in ice_vsi_cfg_rxq()
620 u16 pf_q = ring->vsi->rxq_map[ring->q_index]; in ice_vsi_cfg_rxq()
623 ring->q_index, pf_q); in ice_vsi_cfg_rxq()
636 if (q_idx >= vsi->num_rxq) in ice_vsi_cfg_single_rxq()
637 return -EINVAL; in ice_vsi_cfg_single_rxq()
639 return ice_vsi_cfg_rxq(vsi->rx_rings[q_idx]); in ice_vsi_cfg_single_rxq()
643 * ice_vsi_cfg_frame_size - setup max frame size and Rx buffer length
652 if (!vsi->netdev || test_bit(ICE_FLAG_LEGACY_RX, vsi->back->flags)) { in ice_vsi_cfg_frame_size()
653 ring->max_frame = ICE_MAX_FRAME_LEGACY_RX; in ice_vsi_cfg_frame_size()
654 ring->rx_buf_len = ICE_RXBUF_1664; in ice_vsi_cfg_frame_size()
657 (vsi->netdev->mtu <= ETH_DATA_LEN)) { in ice_vsi_cfg_frame_size()
658 ring->max_frame = ICE_RXBUF_1536 - NET_IP_ALIGN; in ice_vsi_cfg_frame_size()
659 ring->rx_buf_len = ICE_RXBUF_1536 - NET_IP_ALIGN; in ice_vsi_cfg_frame_size()
662 ring->max_frame = ICE_AQ_SET_MAC_FRAME_SIZE_MAX; in ice_vsi_cfg_frame_size()
663 ring->rx_buf_len = ICE_RXBUF_3072; in ice_vsi_cfg_frame_size()
668 * ice_vsi_cfg_rxqs - Configure the VSI for Rx
680 struct ice_rx_ring *ring = vsi->rx_rings[i]; in ice_vsi_cfg_rxqs()
683 if (vsi->type != ICE_VSI_VF) in ice_vsi_cfg_rxqs()
695 * __ice_vsi_get_qs - helper function for assigning queues from PF to VSI
696 * @qs_cfg: gathered variables needed for pf->vsi queues assignment
701 * Return 0 on success and -ENOMEM in case of no left space in PF queue bitmap
710 qs_cfg->mapping_mode = ICE_VSI_MAP_SCATTER; in __ice_vsi_get_qs()
711 qs_cfg->q_count = min_t(unsigned int, qs_cfg->q_count, in __ice_vsi_get_qs()
712 qs_cfg->scatter_count); in __ice_vsi_get_qs()
719 * ice_vsi_ctrl_one_rx_ring - start/stop VSI's Rx ring with no busy wait
722 * @rxq_idx: 0-based Rx queue index for the VSI passed in
723 * @wait: wait or don't wait for configuration to finish in hardware
728 ice_vsi_ctrl_one_rx_ring(struct ice_vsi *vsi, bool ena, u16 rxq_idx, bool wait) in ice_vsi_ctrl_one_rx_ring() argument
730 int pf_q = vsi->rxq_map[rxq_idx]; in ice_vsi_ctrl_one_rx_ring()
731 struct ice_pf *pf = vsi->back; in ice_vsi_ctrl_one_rx_ring()
732 struct ice_hw *hw = &pf->hw; in ice_vsi_ctrl_one_rx_ring()
737 /* Skip if the queue is already in the requested state */ in ice_vsi_ctrl_one_rx_ring()
741 /* turn on/off the queue */ in ice_vsi_ctrl_one_rx_ring()
748 if (!wait) in ice_vsi_ctrl_one_rx_ring()
756 * ice_vsi_wait_one_rx_ring - wait for a VSI's Rx ring to be stopped/started
759 * @rxq_idx: 0-based Rx queue index for the VSI passed in
761 * This routine will wait for the given Rx queue of the VSI to reach the
762 * enabled or disabled state. Returns -ETIMEDOUT in case of failing to reach
768 int pf_q = vsi->rxq_map[rxq_idx]; in ice_vsi_wait_one_rx_ring()
769 struct ice_pf *pf = vsi->back; in ice_vsi_wait_one_rx_ring()
775 * ice_vsi_alloc_q_vectors - Allocate memory for interrupt vectors
778 * We allocate one q_vector per queue interrupt. If allocation fails we
779 * return -ENOMEM.
783 struct device *dev = ice_pf_to_dev(vsi->back); in ice_vsi_alloc_q_vectors()
787 if (vsi->q_vectors[0]) { in ice_vsi_alloc_q_vectors()
788 dev_dbg(dev, "VSI %d has existing q_vectors\n", vsi->vsi_num); in ice_vsi_alloc_q_vectors()
789 return -EEXIST; in ice_vsi_alloc_q_vectors()
792 for (v_idx = 0; v_idx < vsi->num_q_vectors; v_idx++) { in ice_vsi_alloc_q_vectors()
801 while (v_idx--) in ice_vsi_alloc_q_vectors()
805 vsi->num_q_vectors, vsi->vsi_num, err); in ice_vsi_alloc_q_vectors()
806 vsi->num_q_vectors = 0; in ice_vsi_alloc_q_vectors()
811 * ice_vsi_map_rings_to_vectors - Map VSI rings to interrupt vectors
814 * This function maps descriptor rings to the queue-specific vectors allotted
815 * through the MSI-X enabling code. On a constrained vector budget, we map Tx
820 int q_vectors = vsi->num_q_vectors; in ice_vsi_map_rings_to_vectors()
824 /* initially assigning remaining rings count to VSIs num queue value */ in ice_vsi_map_rings_to_vectors()
825 tx_rings_rem = vsi->num_txq; in ice_vsi_map_rings_to_vectors()
826 rx_rings_rem = vsi->num_rxq; in ice_vsi_map_rings_to_vectors()
829 struct ice_q_vector *q_vector = vsi->q_vectors[v_id]; in ice_vsi_map_rings_to_vectors()
835 q_vectors - v_id); in ice_vsi_map_rings_to_vectors()
836 q_vector->num_ring_tx = tx_rings_per_v; in ice_vsi_map_rings_to_vectors()
837 q_vector->tx.tx_ring = NULL; in ice_vsi_map_rings_to_vectors()
838 q_vector->tx.itr_idx = ICE_TX_ITR; in ice_vsi_map_rings_to_vectors()
839 q_base = vsi->num_txq - tx_rings_rem; in ice_vsi_map_rings_to_vectors()
842 struct ice_tx_ring *tx_ring = vsi->tx_rings[q_id]; in ice_vsi_map_rings_to_vectors()
844 tx_ring->q_vector = q_vector; in ice_vsi_map_rings_to_vectors()
845 tx_ring->next = q_vector->tx.tx_ring; in ice_vsi_map_rings_to_vectors()
846 q_vector->tx.tx_ring = tx_ring; in ice_vsi_map_rings_to_vectors()
848 tx_rings_rem -= tx_rings_per_v; in ice_vsi_map_rings_to_vectors()
852 q_vectors - v_id); in ice_vsi_map_rings_to_vectors()
853 q_vector->num_ring_rx = rx_rings_per_v; in ice_vsi_map_rings_to_vectors()
854 q_vector->rx.rx_ring = NULL; in ice_vsi_map_rings_to_vectors()
855 q_vector->rx.itr_idx = ICE_RX_ITR; in ice_vsi_map_rings_to_vectors()
856 q_base = vsi->num_rxq - rx_rings_rem; in ice_vsi_map_rings_to_vectors()
859 struct ice_rx_ring *rx_ring = vsi->rx_rings[q_id]; in ice_vsi_map_rings_to_vectors()
861 rx_ring->q_vector = q_vector; in ice_vsi_map_rings_to_vectors()
862 rx_ring->next = q_vector->rx.rx_ring; in ice_vsi_map_rings_to_vectors()
863 q_vector->rx.rx_ring = rx_ring; in ice_vsi_map_rings_to_vectors()
865 rx_rings_rem -= rx_rings_per_v; in ice_vsi_map_rings_to_vectors()
873 * ice_vsi_free_q_vectors - Free memory allocated for interrupt vectors
883 vsi->num_q_vectors = 0; in ice_vsi_free_q_vectors()
887 * ice_vsi_cfg_txq - Configure single Tx queue
888 * @vsi: the VSI that queue belongs to
890 * @qg_buf: queue group buffer
899 struct ice_channel *ch = ring->ch; in ice_vsi_cfg_txq()
900 struct ice_pf *pf = vsi->back; in ice_vsi_cfg_txq()
901 struct ice_hw *hw = &pf->hw; in ice_vsi_cfg_txq()
909 pf_q = ring->reg_idx; in ice_vsi_cfg_txq()
912 qg_buf->txqs[0].txq_id = cpu_to_le16(pf_q); in ice_vsi_cfg_txq()
913 ice_set_ctx(hw, (u8 *)&tlan_ctx, qg_buf->txqs[0].txq_ctx, in ice_vsi_cfg_txq()
916 /* init queue specific tail reg. It is referred as in ice_vsi_cfg_txq()
917 * transmit comm scheduler queue doorbell. in ice_vsi_cfg_txq()
919 ring->tail = hw->hw_addr + QTX_COMM_DBELL(pf_q); in ice_vsi_cfg_txq()
922 tc = ring->dcb_tc; in ice_vsi_cfg_txq()
926 /* Add unique software queue handle of the Tx queue per in ice_vsi_cfg_txq()
929 ring->q_handle = ice_calc_txq_handle(vsi, ring, tc); in ice_vsi_cfg_txq()
932 status = ice_ena_vsi_txq(vsi->port_info, ch->ch_vsi->idx, 0, in ice_vsi_cfg_txq()
933 ring->q_handle, 1, qg_buf, buf_len, in ice_vsi_cfg_txq()
936 status = ice_ena_vsi_txq(vsi->port_info, vsi->idx, tc, in ice_vsi_cfg_txq()
937 ring->q_handle, 1, qg_buf, buf_len, in ice_vsi_cfg_txq()
940 dev_err(ice_pf_to_dev(pf), "Failed to set LAN Tx queue context, error: %d\n", in ice_vsi_cfg_txq()
945 /* Add Tx Queue TEID into the VSI Tx ring from the in ice_vsi_cfg_txq()
947 * enabling the queue. in ice_vsi_cfg_txq()
949 txq = &qg_buf->txqs[0]; in ice_vsi_cfg_txq()
950 if (pf_q == le16_to_cpu(txq->txq_id)) in ice_vsi_cfg_txq()
951 ring->txq_teid = le32_to_cpu(txq->q_teid); in ice_vsi_cfg_txq()
961 if (q_idx >= vsi->alloc_txq || !tx_rings || !tx_rings[q_idx]) in ice_vsi_cfg_single_txq()
962 return -EINVAL; in ice_vsi_cfg_single_txq()
964 qg_buf->num_txqs = 1; in ice_vsi_cfg_single_txq()
970 * ice_vsi_cfg_txqs - Configure the VSI for Tx
985 qg_buf->num_txqs = 1; in ice_vsi_cfg_txqs()
997 * ice_vsi_cfg_lan_txqs - Configure the VSI for Tx
1005 return ice_vsi_cfg_txqs(vsi, vsi->tx_rings, vsi->num_txq); in ice_vsi_cfg_lan_txqs()
1009 * ice_vsi_cfg_xdp_txqs - Configure Tx queues dedicated for XDP in given VSI
1020 ret = ice_vsi_cfg_txqs(vsi, vsi->xdp_rings, vsi->num_xdp_txq); in ice_vsi_cfg_xdp_txqs()
1031 * ice_cfg_itr - configure the initial interrupt throttle values
1042 if (q_vector->num_ring_rx) in ice_cfg_itr()
1043 ice_write_itr(&q_vector->rx, q_vector->rx.itr_setting); in ice_cfg_itr()
1045 if (q_vector->num_ring_tx) in ice_cfg_itr()
1046 ice_write_itr(&q_vector->tx, q_vector->tx.itr_setting); in ice_cfg_itr()
1048 ice_write_intrl(q_vector, q_vector->intrl); in ice_cfg_itr()
1052 * ice_cfg_txq_interrupt - configure interrupt on Tx queue
1054 * @txq: Tx queue being mapped to MSI-X vector
1055 * @msix_idx: MSI-X vector index within the function
1058 * Configure interrupt on Tx queue by associating Tx queue to MSI-X vector
1064 struct ice_pf *pf = vsi->back; in ice_cfg_txq_interrupt()
1065 struct ice_hw *hw = &pf->hw; in ice_cfg_txq_interrupt()
1073 wr32(hw, QINT_TQCTL(vsi->txq_map[txq]), val); in ice_cfg_txq_interrupt()
1075 u32 xdp_txq = txq + vsi->num_xdp_txq; in ice_cfg_txq_interrupt()
1077 wr32(hw, QINT_TQCTL(vsi->txq_map[xdp_txq]), in ice_cfg_txq_interrupt()
1084 * ice_cfg_rxq_interrupt - configure interrupt on Rx queue
1086 * @rxq: Rx queue being mapped to MSI-X vector
1087 * @msix_idx: MSI-X vector index within the function
1090 * Configure interrupt on Rx queue by associating Rx queue to MSI-X vector
1096 struct ice_pf *pf = vsi->back; in ice_cfg_rxq_interrupt()
1097 struct ice_hw *hw = &pf->hw; in ice_cfg_rxq_interrupt()
1105 wr32(hw, QINT_RQCTL(vsi->rxq_map[rxq]), val); in ice_cfg_rxq_interrupt()
1111 * ice_trigger_sw_intr - trigger a software interrupt
1117 wr32(hw, GLINT_DYN_CTL(q_vector->reg_idx), in ice_trigger_sw_intr()
1124 * ice_vsi_stop_tx_ring - Disable single Tx ring
1136 struct ice_pf *pf = vsi->back; in ice_vsi_stop_tx_ring()
1138 struct ice_hw *hw = &pf->hw; in ice_vsi_stop_tx_ring()
1143 val = rd32(hw, QINT_TQCTL(ring->reg_idx)); in ice_vsi_stop_tx_ring()
1145 wr32(hw, QINT_TQCTL(ring->reg_idx), val); in ice_vsi_stop_tx_ring()
1147 /* software is expected to wait for 100 ns */ in ice_vsi_stop_tx_ring()
1151 * associated to the queue to schedule NAPI handler in ice_vsi_stop_tx_ring()
1153 q_vector = ring->q_vector; in ice_vsi_stop_tx_ring()
1154 if (q_vector && !(vsi->vf && ice_is_vf_disabled(vsi->vf))) in ice_vsi_stop_tx_ring()
1157 status = ice_dis_vsi_txq(vsi->port_info, txq_meta->vsi_idx, in ice_vsi_stop_tx_ring()
1158 txq_meta->tc, 1, &txq_meta->q_handle, in ice_vsi_stop_tx_ring()
1159 &txq_meta->q_id, &txq_meta->q_teid, rst_src, in ice_vsi_stop_tx_ring()
1162 /* if the disable queue command was exercised during an in ice_vsi_stop_tx_ring()
1163 * active reset flow, -EBUSY is returned. in ice_vsi_stop_tx_ring()
1167 if (status == -EBUSY) { in ice_vsi_stop_tx_ring()
1168 dev_dbg(ice_pf_to_dev(vsi->back), "Reset in progress. LAN Tx queues already disabled\n"); in ice_vsi_stop_tx_ring()
1169 } else if (status == -ENOENT) { in ice_vsi_stop_tx_ring()
1170 dev_dbg(ice_pf_to_dev(vsi->back), "LAN Tx queues do not exist, nothing to disable\n"); in ice_vsi_stop_tx_ring()
1172 dev_dbg(ice_pf_to_dev(vsi->back), "Failed to disable LAN Tx queues, error: %d\n", in ice_vsi_stop_tx_ring()
1181 * ice_fill_txq_meta - Prepare the Tx queue's meta data
1184 * @txq_meta: a helper struct that wraps Tx queue's information
1187 * are needed for stopping Tx queue
1193 struct ice_channel *ch = ring->ch; in ice_fill_txq_meta()
1197 tc = ring->dcb_tc; in ice_fill_txq_meta()
1201 txq_meta->q_id = ring->reg_idx; in ice_fill_txq_meta()
1202 txq_meta->q_teid = ring->txq_teid; in ice_fill_txq_meta()
1203 txq_meta->q_handle = ring->q_handle; in ice_fill_txq_meta()
1205 txq_meta->vsi_idx = ch->ch_vsi->idx; in ice_fill_txq_meta()
1206 txq_meta->tc = 0; in ice_fill_txq_meta()
1208 txq_meta->vsi_idx = vsi->idx; in ice_fill_txq_meta()
1209 txq_meta->tc = tc; in ice_fill_txq_meta()