]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
idpf: preserve coalescing settings across resets
authorAhmed Zaki <ahmed.zaki@intel.com>
Fri, 20 Jun 2025 17:15:48 +0000 (11:15 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Aug 2025 16:41:06 +0000 (18:41 +0200)
[ Upstream commit e1e3fec3e34b4934a9d2c98e4ee00a4d87b19179 ]

The IRQ coalescing config currently reside only inside struct
idpf_q_vector. However, all idpf_q_vector structs are de-allocated and
re-allocated during resets. This leads to user-set coalesce configuration
to be lost.

Add new fields to struct idpf_vport_user_config_data to save the user
settings and re-apply them after reset.

Reviewed-by: Madhu Chittim <madhu.chittim@intel.com>
Signed-off-by: Ahmed Zaki <ahmed.zaki@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Tested-by: Samuel Salin <Samuel.salin@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/intel/idpf/idpf.h
drivers/net/ethernet/intel/idpf/idpf_ethtool.c
drivers/net/ethernet/intel/idpf/idpf_lib.c
drivers/net/ethernet/intel/idpf/idpf_main.c
drivers/net/ethernet/intel/idpf/idpf_txrx.c

index 1e812c3f62f9b8baf791adb920ebc4ed53482111..0bb9cab2b3c3af599f6ef094308b617a751e2503 100644 (file)
@@ -378,10 +378,28 @@ struct idpf_rss_data {
        u32 *cached_lut;
 };
 
+/**
+ * struct idpf_q_coalesce - User defined coalescing configuration values for
+ *                        a single queue.
+ * @tx_intr_mode: Dynamic TX ITR or not
+ * @rx_intr_mode: Dynamic RX ITR or not
+ * @tx_coalesce_usecs: TX interrupt throttling rate
+ * @rx_coalesce_usecs: RX interrupt throttling rate
+ *
+ * Used to restore user coalescing configuration after a reset.
+ */
+struct idpf_q_coalesce {
+       u32 tx_intr_mode;
+       u32 rx_intr_mode;
+       u32 tx_coalesce_usecs;
+       u32 rx_coalesce_usecs;
+};
+
 /**
  * struct idpf_vport_user_config_data - User defined configuration values for
  *                                     each vport.
  * @rss_data: See struct idpf_rss_data
+ * @q_coalesce: Array of per queue coalescing data
  * @num_req_tx_qs: Number of user requested TX queues through ethtool
  * @num_req_rx_qs: Number of user requested RX queues through ethtool
  * @num_req_txq_desc: Number of user requested TX queue descriptors through
@@ -395,6 +413,7 @@ struct idpf_rss_data {
  */
 struct idpf_vport_user_config_data {
        struct idpf_rss_data rss_data;
+       struct idpf_q_coalesce *q_coalesce;
        u16 num_req_tx_qs;
        u16 num_req_rx_qs;
        u32 num_req_txq_desc;
index eaf7a2606faaa06c451141c4614977494b06cb03..f7599cd2aabf46b6537601b84fe4172484f07ad6 100644 (file)
@@ -1090,12 +1090,14 @@ static int idpf_get_per_q_coalesce(struct net_device *netdev, u32 q_num,
 /**
  * __idpf_set_q_coalesce - set ITR values for specific queue
  * @ec: ethtool structure from user to update ITR settings
+ * @q_coal: per queue coalesce settings
  * @qv: queue vector for which itr values has to be set
  * @is_rxq: is queue type rx
  *
  * Returns 0 on success, negative otherwise.
  */
 static int __idpf_set_q_coalesce(const struct ethtool_coalesce *ec,
+                                struct idpf_q_coalesce *q_coal,
                                 struct idpf_q_vector *qv, bool is_rxq)
 {
        u32 use_adaptive_coalesce, coalesce_usecs;
@@ -1139,20 +1141,25 @@ static int __idpf_set_q_coalesce(const struct ethtool_coalesce *ec,
 
        if (is_rxq) {
                qv->rx_itr_value = coalesce_usecs;
+               q_coal->rx_coalesce_usecs = coalesce_usecs;
                if (use_adaptive_coalesce) {
                        qv->rx_intr_mode = IDPF_ITR_DYNAMIC;
+                       q_coal->rx_intr_mode = IDPF_ITR_DYNAMIC;
                } else {
                        qv->rx_intr_mode = !IDPF_ITR_DYNAMIC;
-                       idpf_vport_intr_write_itr(qv, qv->rx_itr_value,
-                                                 false);
+                       q_coal->rx_intr_mode = !IDPF_ITR_DYNAMIC;
+                       idpf_vport_intr_write_itr(qv, coalesce_usecs, false);
                }
        } else {
                qv->tx_itr_value = coalesce_usecs;
+               q_coal->tx_coalesce_usecs = coalesce_usecs;
                if (use_adaptive_coalesce) {
                        qv->tx_intr_mode = IDPF_ITR_DYNAMIC;
+                       q_coal->tx_intr_mode = IDPF_ITR_DYNAMIC;
                } else {
                        qv->tx_intr_mode = !IDPF_ITR_DYNAMIC;
-                       idpf_vport_intr_write_itr(qv, qv->tx_itr_value, true);
+                       q_coal->tx_intr_mode = !IDPF_ITR_DYNAMIC;
+                       idpf_vport_intr_write_itr(qv, coalesce_usecs, true);
                }
        }
 
@@ -1165,6 +1172,7 @@ static int __idpf_set_q_coalesce(const struct ethtool_coalesce *ec,
 /**
  * idpf_set_q_coalesce - set ITR values for specific queue
  * @vport: vport associated to the queue that need updating
+ * @q_coal: per queue coalesce settings
  * @ec: coalesce settings to program the device with
  * @q_num: update ITR/INTRL (coalesce) settings for this queue number/index
  * @is_rxq: is queue type rx
@@ -1172,6 +1180,7 @@ static int __idpf_set_q_coalesce(const struct ethtool_coalesce *ec,
  * Return 0 on success, and negative on failure
  */
 static int idpf_set_q_coalesce(const struct idpf_vport *vport,
+                              struct idpf_q_coalesce *q_coal,
                               const struct ethtool_coalesce *ec,
                               int q_num, bool is_rxq)
 {
@@ -1180,7 +1189,7 @@ static int idpf_set_q_coalesce(const struct idpf_vport *vport,
        qv = is_rxq ? idpf_find_rxq_vec(vport, q_num) :
                      idpf_find_txq_vec(vport, q_num);
 
-       if (qv && __idpf_set_q_coalesce(ec, qv, is_rxq))
+       if (qv && __idpf_set_q_coalesce(ec, q_coal, qv, is_rxq))
                return -EINVAL;
 
        return 0;
@@ -1201,9 +1210,13 @@ static int idpf_set_coalesce(struct net_device *netdev,
                             struct netlink_ext_ack *extack)
 {
        struct idpf_netdev_priv *np = netdev_priv(netdev);
+       struct idpf_vport_user_config_data *user_config;
+       struct idpf_q_coalesce *q_coal;
        struct idpf_vport *vport;
        int i, err = 0;
 
+       user_config = &np->adapter->vport_config[np->vport_idx]->user_config;
+
        idpf_vport_ctrl_lock(netdev);
        vport = idpf_netdev_to_vport(netdev);
 
@@ -1211,13 +1224,15 @@ static int idpf_set_coalesce(struct net_device *netdev,
                goto unlock_mutex;
 
        for (i = 0; i < vport->num_txq; i++) {
-               err = idpf_set_q_coalesce(vport, ec, i, false);
+               q_coal = &user_config->q_coalesce[i];
+               err = idpf_set_q_coalesce(vport, q_coal, ec, i, false);
                if (err)
                        goto unlock_mutex;
        }
 
        for (i = 0; i < vport->num_rxq; i++) {
-               err = idpf_set_q_coalesce(vport, ec, i, true);
+               q_coal = &user_config->q_coalesce[i];
+               err = idpf_set_q_coalesce(vport, q_coal, ec, i, true);
                if (err)
                        goto unlock_mutex;
        }
@@ -1239,20 +1254,25 @@ unlock_mutex:
 static int idpf_set_per_q_coalesce(struct net_device *netdev, u32 q_num,
                                   struct ethtool_coalesce *ec)
 {
+       struct idpf_netdev_priv *np = netdev_priv(netdev);
+       struct idpf_vport_user_config_data *user_config;
+       struct idpf_q_coalesce *q_coal;
        struct idpf_vport *vport;
        int err;
 
        idpf_vport_ctrl_lock(netdev);
        vport = idpf_netdev_to_vport(netdev);
+       user_config = &np->adapter->vport_config[np->vport_idx]->user_config;
+       q_coal = &user_config->q_coalesce[q_num];
 
-       err = idpf_set_q_coalesce(vport, ec, q_num, false);
+       err = idpf_set_q_coalesce(vport, q_coal, ec, q_num, false);
        if (err) {
                idpf_vport_ctrl_unlock(netdev);
 
                return err;
        }
 
-       err = idpf_set_q_coalesce(vport, ec, q_num, true);
+       err = idpf_set_q_coalesce(vport, q_coal, ec, q_num, true);
 
        idpf_vport_ctrl_unlock(netdev);
 
index 80382ff4a5fa00ae1ba5fb7b2fdeaad5575189ce..e9f8da9f7979bebc0199cc6c1d54b01099a932e3 100644 (file)
@@ -1079,8 +1079,10 @@ static struct idpf_vport *idpf_vport_alloc(struct idpf_adapter *adapter,
        if (!vport)
                return vport;
 
+       num_max_q = max(max_q->max_txq, max_q->max_rxq);
        if (!adapter->vport_config[idx]) {
                struct idpf_vport_config *vport_config;
+               struct idpf_q_coalesce *q_coal;
 
                vport_config = kzalloc(sizeof(*vport_config), GFP_KERNEL);
                if (!vport_config) {
@@ -1089,6 +1091,21 @@ static struct idpf_vport *idpf_vport_alloc(struct idpf_adapter *adapter,
                        return NULL;
                }
 
+               q_coal = kcalloc(num_max_q, sizeof(*q_coal), GFP_KERNEL);
+               if (!q_coal) {
+                       kfree(vport_config);
+                       kfree(vport);
+
+                       return NULL;
+               }
+               for (int i = 0; i < num_max_q; i++) {
+                       q_coal[i].tx_intr_mode = IDPF_ITR_DYNAMIC;
+                       q_coal[i].tx_coalesce_usecs = IDPF_ITR_TX_DEF;
+                       q_coal[i].rx_intr_mode = IDPF_ITR_DYNAMIC;
+                       q_coal[i].rx_coalesce_usecs = IDPF_ITR_RX_DEF;
+               }
+               vport_config->user_config.q_coalesce = q_coal;
+
                adapter->vport_config[idx] = vport_config;
        }
 
@@ -1098,7 +1115,6 @@ static struct idpf_vport *idpf_vport_alloc(struct idpf_adapter *adapter,
        vport->default_vport = adapter->num_alloc_vports <
                               idpf_get_default_vports(adapter);
 
-       num_max_q = max(max_q->max_txq, max_q->max_rxq);
        vport->q_vector_idxs = kcalloc(num_max_q, sizeof(u16), GFP_KERNEL);
        if (!vport->q_vector_idxs)
                goto free_vport;
index 0efd9c0c7a90fe207f2af4f3e9e06f54a64eb4ad..6e0757ab406ebb964490f84344e1b5b6937abbef 100644 (file)
@@ -62,6 +62,7 @@ destroy_wqs:
        destroy_workqueue(adapter->vc_event_wq);
 
        for (i = 0; i < adapter->max_vports; i++) {
+               kfree(adapter->vport_config[i]->user_config.q_coalesce);
                kfree(adapter->vport_config[i]);
                adapter->vport_config[i] = NULL;
        }
index 5cf440e09d0a6701633e91a9f46b07ba1eff5bfb..89185d1b8485ee74628ed84e1f9a50b100ae1f8d 100644 (file)
@@ -4349,9 +4349,13 @@ static void idpf_vport_intr_napi_add_all(struct idpf_vport *vport)
 int idpf_vport_intr_alloc(struct idpf_vport *vport)
 {
        u16 txqs_per_vector, rxqs_per_vector, bufqs_per_vector;
+       struct idpf_vport_user_config_data *user_config;
        struct idpf_q_vector *q_vector;
+       struct idpf_q_coalesce *q_coal;
        u32 complqs_per_vector, v_idx;
+       u16 idx = vport->idx;
 
+       user_config = &vport->adapter->vport_config[idx]->user_config;
        vport->q_vectors = kcalloc(vport->num_q_vectors,
                                   sizeof(struct idpf_q_vector), GFP_KERNEL);
        if (!vport->q_vectors)
@@ -4369,14 +4373,15 @@ int idpf_vport_intr_alloc(struct idpf_vport *vport)
 
        for (v_idx = 0; v_idx < vport->num_q_vectors; v_idx++) {
                q_vector = &vport->q_vectors[v_idx];
+               q_coal = &user_config->q_coalesce[v_idx];
                q_vector->vport = vport;
 
-               q_vector->tx_itr_value = IDPF_ITR_TX_DEF;
-               q_vector->tx_intr_mode = IDPF_ITR_DYNAMIC;
+               q_vector->tx_itr_value = q_coal->tx_coalesce_usecs;
+               q_vector->tx_intr_mode = q_coal->tx_intr_mode;
                q_vector->tx_itr_idx = VIRTCHNL2_ITR_IDX_1;
 
-               q_vector->rx_itr_value = IDPF_ITR_RX_DEF;
-               q_vector->rx_intr_mode = IDPF_ITR_DYNAMIC;
+               q_vector->rx_itr_value = q_coal->rx_coalesce_usecs;
+               q_vector->rx_intr_mode = q_coal->rx_intr_mode;
                q_vector->rx_itr_idx = VIRTCHNL2_ITR_IDX_0;
 
                q_vector->tx = kcalloc(txqs_per_vector, sizeof(*q_vector->tx),