The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d6958f3faec023dfb7be5c01133c1a70c779e7b5

commit d6958f3faec023dfb7be5c01133c1a70c779e7b5
Author:     Krzysztof Galazka <krzysztof.gala...@intel.com>
AuthorDate: 2025-03-06 21:47:31 +0000
Commit:     Warner Losh <i...@freebsd.org>
CommitDate: 2025-07-18 19:16:16 +0000

    ice(4): Fix re-enabling VF queues
    
    On receiving a virtual channel request from VF driver tried
    to configure and enable Tx and Rx queues without making
    sure that they were disabled. It caused issue with reloading
    a VF driver without a reset e.g. in case it crashed.
    Fix that by always disabling all Rx and Tx queues.
    
    While at that make sure that only queues requested by VF
    driver are enabled. VF driver may use less queues than
    assigned to the function when it was created.
    
    Signed-off-by: Krzysztof Galazka <krzysztof.gala...@intel.com>
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1573
---
 sys/dev/ice/ice_iov.c | 31 ++++++++++++++++++++++++++-----
 sys/dev/ice/ice_lib.c |  8 ++++++++
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/sys/dev/ice/ice_iov.c b/sys/dev/ice/ice_iov.c
index af0bef7bf2f0..3785a6c8dd13 100644
--- a/sys/dev/ice/ice_iov.c
+++ b/sys/dev/ice/ice_iov.c
@@ -925,7 +925,9 @@ ice_vc_cfg_vsi_qs_msg(struct ice_softc *sc, struct ice_vf 
*vf, u8 *msg_buf)
        struct virtchnl_queue_pair_info *vqpi;
        enum virtchnl_status_code status = VIRTCHNL_STATUS_SUCCESS;
        struct ice_vsi *vsi = vf->vsi;
-       int error = 0;
+       struct ice_tx_queue *txq;
+       struct ice_rx_queue *rxq;
+       int i, error = 0;
 
        vqci = (struct virtchnl_vsi_queue_config_info *)msg_buf;
 
@@ -935,11 +937,30 @@ ice_vc_cfg_vsi_qs_msg(struct ice_softc *sc, struct ice_vf 
*vf, u8 *msg_buf)
                goto done;
        }
 
-       vqpi = vqci->qpair;
-       for (int i = 0; i < vqci->num_queue_pairs; i++, vqpi++) {
-               struct ice_tx_queue *txq;
-               struct ice_rx_queue *rxq;
+       ice_vsi_disable_tx(vf->vsi);
+       ice_control_all_rx_queues(vf->vsi, false);
+
+       /*
+        * Clear TX and RX queues config in case VF
+        * requests different number of queues.
+        */
+       for (i = 0; i < vsi->num_tx_queues; i++) {
+               txq = &vsi->tx_queues[i];
+
+               txq->desc_count = 0;
+               txq->tx_paddr = 0;
+               txq->tc = 0;
+       }
 
+       for (i = 0; i < vsi->num_rx_queues; i++) {
+               rxq = &vsi->rx_queues[i];
+
+               rxq->desc_count = 0;
+               rxq->rx_paddr = 0;
+       }
+
+       vqpi = vqci->qpair;
+       for (i = 0; i < vqci->num_queue_pairs; i++, vqpi++) {
                /* Initial parameter validation */
                if (vqpi->txq.vsi_id != vf->vsi->idx ||
                    vqpi->rxq.vsi_id != vf->vsi->idx ||
diff --git a/sys/dev/ice/ice_lib.c b/sys/dev/ice/ice_lib.c
index 3e8b9c85c5ae..442111e5ffaf 100644
--- a/sys/dev/ice/ice_lib.c
+++ b/sys/dev/ice/ice_lib.c
@@ -1675,6 +1675,10 @@ ice_cfg_vsi_for_tx(struct ice_vsi *vsi)
                struct ice_tlan_ctx tlan_ctx = { 0 };
                struct ice_tx_queue *txq = &vsi->tx_queues[i];
 
+               /* Last configured queue */
+               if (txq->desc_count == 0)
+                       break;
+
                pf_q = vsi->tx_qmap[txq->me];
                qg->txqs[0].txq_id = htole16(pf_q);
 
@@ -1803,6 +1807,10 @@ ice_cfg_vsi_for_rx(struct ice_vsi *vsi)
 
        for (i = 0; i < vsi->num_rx_queues; i++) {
                MPASS(vsi->mbuf_sz > 0);
+               /* Last configured queue */
+               if (vsi->rx_queues[i].desc_count == 0)
+                       break;
+
                err = ice_setup_rx_ctx(&vsi->rx_queues[i]);
                if (err)
                        return err;

Reply via email to