net/bnxt: fix queue start/stop operations
[dpdk.git] / drivers / net / bnxt / bnxt_hwrm.c
index ba4ef16..64687a6 100644 (file)
@@ -506,6 +506,7 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
        if (BNXT_PF(bp)) {
                bp->pf.port_id = resp->port_id;
                bp->pf.first_vf_id = rte_le_to_cpu_16(resp->first_vf_id);
+               bp->pf.total_vfs = rte_le_to_cpu_16(resp->max_vfs);
                new_max_vfs = bp->pdev->max_vfs;
                if (new_max_vfs != bp->pf.max_vfs) {
                        if (bp->pf.vf_info)
@@ -1816,8 +1817,7 @@ int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp)
        return rc;
 }
 
-static void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
-                               unsigned int idx __rte_unused)
+static void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
 {
        struct bnxt_ring *cp_ring = cpr->cp_ring_struct;
 
@@ -1829,17 +1829,52 @@ static void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
        cpr->cp_raw_cons = 0;
 }
 
+void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index)
+{
+       struct bnxt_rx_queue *rxq = bp->rx_queues[queue_index];
+       struct bnxt_rx_ring_info *rxr = rxq->rx_ring;
+       struct bnxt_ring *ring = rxr->rx_ring_struct;
+       struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
+
+       if (ring->fw_ring_id != INVALID_HW_RING_ID) {
+               bnxt_hwrm_ring_free(bp, ring,
+                                   HWRM_RING_FREE_INPUT_RING_TYPE_RX);
+               ring->fw_ring_id = INVALID_HW_RING_ID;
+               bp->grp_info[queue_index].rx_fw_ring_id = INVALID_HW_RING_ID;
+               memset(rxr->rx_desc_ring, 0,
+                      rxr->rx_ring_struct->ring_size *
+                      sizeof(*rxr->rx_desc_ring));
+               memset(rxr->rx_buf_ring, 0,
+                      rxr->rx_ring_struct->ring_size *
+                      sizeof(*rxr->rx_buf_ring));
+               rxr->rx_prod = 0;
+       }
+       ring = rxr->ag_ring_struct;
+       if (ring->fw_ring_id != INVALID_HW_RING_ID) {
+               bnxt_hwrm_ring_free(bp, ring,
+                                   HWRM_RING_FREE_INPUT_RING_TYPE_RX);
+               ring->fw_ring_id = INVALID_HW_RING_ID;
+               memset(rxr->ag_buf_ring, 0,
+                      rxr->ag_ring_struct->ring_size *
+                      sizeof(*rxr->ag_buf_ring));
+               rxr->ag_prod = 0;
+               bp->grp_info[queue_index].ag_fw_ring_id = INVALID_HW_RING_ID;
+       }
+       if (cpr->cp_ring_struct->fw_ring_id != INVALID_HW_RING_ID)
+               bnxt_free_cp_ring(bp, cpr);
+
+       bp->grp_info[queue_index].cp_fw_ring_id = INVALID_HW_RING_ID;
+}
+
 int bnxt_free_all_hwrm_rings(struct bnxt *bp)
 {
        unsigned int i;
-       int rc = 0;
 
        for (i = 0; i < bp->tx_cp_nr_rings; i++) {
                struct bnxt_tx_queue *txq = bp->tx_queues[i];
                struct bnxt_tx_ring_info *txr = txq->tx_ring;
                struct bnxt_ring *ring = txr->tx_ring_struct;
                struct bnxt_cp_ring_info *cpr = txq->cp_ring;
-               unsigned int idx = bp->rx_cp_nr_rings + i;
 
                if (ring->fw_ring_id != INVALID_HW_RING_ID) {
                        bnxt_hwrm_ring_free(bp, ring,
@@ -1855,59 +1890,15 @@ int bnxt_free_all_hwrm_rings(struct bnxt *bp)
                        txr->tx_cons = 0;
                }
                if (cpr->cp_ring_struct->fw_ring_id != INVALID_HW_RING_ID) {
-                       bnxt_free_cp_ring(bp, cpr, idx);
+                       bnxt_free_cp_ring(bp, cpr);
                        cpr->cp_ring_struct->fw_ring_id = INVALID_HW_RING_ID;
                }
        }
 
-       for (i = 0; i < bp->rx_cp_nr_rings; i++) {
-               struct bnxt_rx_queue *rxq = bp->rx_queues[i];
-               struct bnxt_rx_ring_info *rxr = rxq->rx_ring;
-               struct bnxt_ring *ring = rxr->rx_ring_struct;
-               struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
-
-               if (ring->fw_ring_id != INVALID_HW_RING_ID) {
-                       bnxt_hwrm_ring_free(bp, ring,
-                                       HWRM_RING_FREE_INPUT_RING_TYPE_RX);
-                       ring->fw_ring_id = INVALID_HW_RING_ID;
-                       bp->grp_info[i].rx_fw_ring_id = INVALID_HW_RING_ID;
-                       memset(rxr->rx_desc_ring, 0,
-                                       rxr->rx_ring_struct->ring_size *
-                                       sizeof(*rxr->rx_desc_ring));
-                       memset(rxr->rx_buf_ring, 0,
-                                       rxr->rx_ring_struct->ring_size *
-                                       sizeof(*rxr->rx_buf_ring));
-                       rxr->rx_prod = 0;
-               }
-               ring = rxr->ag_ring_struct;
-               if (ring->fw_ring_id != INVALID_HW_RING_ID) {
-                       bnxt_hwrm_ring_free(bp, ring,
-                                           HWRM_RING_FREE_INPUT_RING_TYPE_RX);
-                       ring->fw_ring_id = INVALID_HW_RING_ID;
-                       memset(rxr->ag_buf_ring, 0,
-                              rxr->ag_ring_struct->ring_size *
-                              sizeof(*rxr->ag_buf_ring));
-                       rxr->ag_prod = 0;
-                       bp->grp_info[i].ag_fw_ring_id = INVALID_HW_RING_ID;
-               }
-               if (cpr->cp_ring_struct->fw_ring_id != INVALID_HW_RING_ID) {
-                       bnxt_free_cp_ring(bp, cpr, i);
-                       bp->grp_info[i].cp_fw_ring_id = INVALID_HW_RING_ID;
-                       cpr->cp_ring_struct->fw_ring_id = INVALID_HW_RING_ID;
-               }
-       }
-
-       /* Default completion ring */
-       {
-               struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
-
-               if (cpr->cp_ring_struct->fw_ring_id != INVALID_HW_RING_ID) {
-                       bnxt_free_cp_ring(bp, cpr, 0);
-                       cpr->cp_ring_struct->fw_ring_id = INVALID_HW_RING_ID;
-               }
-       }
+       for (i = 0; i < bp->rx_cp_nr_rings; i++)
+               bnxt_free_hwrm_rx_ring(bp, i);
 
-       return rc;
+       return 0;
 }
 
 int bnxt_alloc_all_hwrm_ring_grps(struct bnxt *bp)
@@ -3131,9 +3122,6 @@ int bnxt_hwrm_port_qstats(struct bnxt *bp)
        struct bnxt_pf_info *pf = &bp->pf;
        int rc;
 
-       if (!(bp->flags & BNXT_FLAG_PORT_STATS))
-               return 0;
-
        HWRM_PREP(req, PORT_QSTATS);
 
        req.port_id = rte_cpu_to_le_16(pf->port_id);
@@ -3154,7 +3142,9 @@ int bnxt_hwrm_port_clr_stats(struct bnxt *bp)
        struct bnxt_pf_info *pf = &bp->pf;
        int rc;
 
-       if (!(bp->flags & BNXT_FLAG_PORT_STATS))
+       /* Not allowed on NS2 device, NPAR, MultiHost, VF */
+       if (!(bp->flags & BNXT_FLAG_PORT_STATS) || BNXT_VF(bp) ||
+           BNXT_NPAR(bp) || BNXT_MH(bp) || BNXT_TOTAL_VFS(bp))
                return 0;
 
        HWRM_PREP(req, PORT_CLR_STATS);
@@ -3835,3 +3825,54 @@ int bnxt_vnic_rss_configure(struct bnxt *bp, struct bnxt_vnic_info *vnic)
        }
        return 0;
 }
+
+static void bnxt_hwrm_set_coal_params(struct bnxt_coal *hw_coal,
+       struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req)
+{
+       uint16_t flags;
+
+       req->num_cmpl_aggr_int = rte_cpu_to_le_16(hw_coal->num_cmpl_aggr_int);
+
+       /* This is a 6-bit value and must not be 0, or we'll get non stop IRQ */
+       req->num_cmpl_dma_aggr = rte_cpu_to_le_16(hw_coal->num_cmpl_dma_aggr);
+
+       /* This is a 6-bit value and must not be 0, or we'll get non stop IRQ */
+       req->num_cmpl_dma_aggr_during_int =
+               rte_cpu_to_le_16(hw_coal->num_cmpl_dma_aggr_during_int);
+
+       req->int_lat_tmr_max = rte_cpu_to_le_16(hw_coal->int_lat_tmr_max);
+
+       /* min timer set to 1/2 of interrupt timer */
+       req->int_lat_tmr_min = rte_cpu_to_le_16(hw_coal->int_lat_tmr_min);
+
+       /* buf timer set to 1/4 of interrupt timer */
+       req->cmpl_aggr_dma_tmr = rte_cpu_to_le_16(hw_coal->cmpl_aggr_dma_tmr);
+
+       req->cmpl_aggr_dma_tmr_during_int =
+               rte_cpu_to_le_16(hw_coal->cmpl_aggr_dma_tmr_during_int);
+
+       flags = HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_TIMER_RESET |
+               HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_RING_IDLE;
+       req->flags = rte_cpu_to_le_16(flags);
+}
+
+int bnxt_hwrm_set_ring_coal(struct bnxt *bp,
+                       struct bnxt_coal *coal, uint16_t ring_id)
+{
+       struct hwrm_ring_cmpl_ring_cfg_aggint_params_input req = {0};
+       struct hwrm_ring_cmpl_ring_cfg_aggint_params_output *resp =
+                                               bp->hwrm_cmd_resp_addr;
+       int rc;
+
+       /* Set ring coalesce parameters only for Stratus 100G NIC */
+       if (!bnxt_stratus_device(bp))
+               return 0;
+
+       HWRM_PREP(req, RING_CMPL_RING_CFG_AGGINT_PARAMS);
+       bnxt_hwrm_set_coal_params(coal, &req);
+       req.ring_id = rte_cpu_to_le_16(ring_id);
+       rc = bnxt_hwrm_send_message(bp, &req, sizeof(req));
+       HWRM_CHECK_RESULT();
+       HWRM_UNLOCK();
+       return 0;
+}