From: Lingyu Liu <lingyu.liu@intel.com>
To: intel-wired-lan@lists.osuosl.org
Cc: kevin.tian@intel.com, yi.l.liu@intel.com, phani.r.burra@intel.com
Subject: [Intel-wired-lan] [PATCH iwl-next V1 11/15] ice: stop device before saving device states
Date: Tue, 20 Jun 2023 09:59:57 +0000 [thread overview]
Message-ID: <20230620100001.5331-12-lingyu.liu@intel.com> (raw)
In-Reply-To: <20230620100001.5331-1-lingyu.liu@intel.com>
Stop device by disabling TX queue and RX queue.
ice_vfio_pci driver introduced in following patches from this
series needs this function when device state transits from
VFIO_DEVICE_STATE_RUNNING to VFIO_DEVICE_STATE_STOP.
Signed-off-by: Lingyu Liu <lingyu.liu@intel.com>
Signed-off-by: Yahui Cao <yahui.cao@intel.com>
---
.../net/ethernet/intel/ice/ice_migration.c | 68 +++++++++++++++++++
include/linux/net/intel/ice_migration.h | 5 ++
2 files changed, 73 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_migration.c b/drivers/net/ethernet/intel/ice/ice_migration.c
index c2a83a97af05..c588738828ab 100644
--- a/drivers/net/ethernet/intel/ice/ice_migration.c
+++ b/drivers/net/ethernet/intel/ice/ice_migration.c
@@ -2,6 +2,8 @@
/* Copyright (C) 2018-2023 Intel Corporation */
#include "ice.h"
+#include "ice_lib.h"
+#include "ice_fltr.h"
#include "ice_base.h"
#include "ice_txrx_lib.h"
@@ -172,6 +174,72 @@ void ice_migration_save_vf_msg(struct ice_vf *vf,
}
}
+/**
+ * ice_migration_suspend_vf - suspend device on src
+ * @opaque: pointer to VF handler in ice vdev
+ * @is_dst: false: migration src true: migration dst
+ *
+ * Return 0 for success, negative for error
+ */
+int ice_migration_suspend_vf(void *opaque, bool is_dst)
+{
+ struct ice_vf *vf = (struct ice_vf *)opaque;
+ struct ice_vsi *vsi = ice_get_vf_vsi(vf);
+ struct ice_pf *pf = vf->pf;
+ struct device *dev;
+ int ret;
+
+ if (is_dst)
+ return 0;
+
+ dev = ice_pf_to_dev(pf);
+ if (vf->virtchnl_msg_num >= VIRTCHNL_MSG_MAX) {
+ dev_err(dev, "SR-IOV live migration disabled on VF %d. Migration buffer exceeded\n",
+ vf->vf_id);
+ return -EIO;
+ }
+
+ if (!vsi) {
+ dev_err(dev, "VF %d VSI is NULL\n", vf->vf_id);
+ return -EINVAL;
+ }
+ /* Prevent VSI from incoming packets by removing all filters before
+ * stop rx ring and draining the traffic. There are possibilities that
+ * rx ring head value jitters when rx ring is stopped with large amount
+ * of packets incoming. In this case, HW mismatches SW on rx ring head
+ * state. As a result, after restoring rx ring head on the destination
+ * VM, the missing rx descriptors will never be written back, causing
+ * packets receiving failure and dropped.
+ */
+ ice_fltr_remove_all(vsi);
+ /* MAC based filter rule is disabled at this point. Set MAC to zero
+ * to keep consistency when using ip link to display MAC address.
+ */
+ eth_zero_addr(vf->hw_lan_addr);
+ eth_zero_addr(vf->dev_lan_addr);
+ /* For the tx side, there is possibility that some descriptors are
+ * still pending to be transmitted by HW. Since VM is stopped now,
+ * wait a while to make sure all the transmission is completed.
+ * For the rx side, head value jittering may happen in case of high
+ * packet rate. Since all forwarding filters are removed now, wait a
+ * while to make sure all the reception is completed and rx head no
+ * longer moves.
+ */
+ usleep_range(1000, 2000);
+ ret = ice_vsi_stop_lan_tx_rings(vsi, ICE_NO_RESET, vf->vf_id);
+ if (ret) {
+ dev_err(dev, "VF %d failed to stop tx rings\n", vf->vf_id);
+ return -EIO;
+ }
+ ret = ice_vsi_stop_all_rx_rings(vsi);
+ if (ret) {
+ dev_err(dev, "VF %d failed to stop rx rings\n", vf->vf_id);
+ return -EIO;
+ }
+ return 0;
+}
+EXPORT_SYMBOL(ice_migration_suspend_vf);
+
static int
ice_migration_save_rx_head(struct ice_vf *vf,
struct ice_migration_dev_state *devstate)
diff --git a/include/linux/net/intel/ice_migration.h b/include/linux/net/intel/ice_migration.h
index b59200a0a059..45c3469df55d 100644
--- a/include/linux/net/intel/ice_migration.h
+++ b/include/linux/net/intel/ice_migration.h
@@ -16,6 +16,7 @@ void *ice_migration_get_vf(struct pci_dev *vf_pdev);
void ice_migration_put_vf(void *opaque);
void ice_migration_init_vf(void *opaque);
void ice_migration_uninit_vf(void *opaque);
+int ice_migration_suspend_vf(void *opaque, bool mig_dst);
int ice_migration_save_devstate(void *opaque, u8 *buf, u64 buf_sz);
int ice_migration_restore_devstate(void *opaque, const u8 *buf, u64 buf_sz,
struct vfio_device *vdev);
@@ -31,6 +32,10 @@ static inline void ice_migration_put_vf(void *opaque)
}
static inline void ice_migration_init_vf(void *opaque) { }
static inline void ice_migration_uninit_vf(void *opaque) { }
+static inline int ice_migration_suspend_vf(void *opaque, bool mig_dst)
+{
+ return 0;
+}
static inline int ice_migration_save_devstate(void *opaque, u8 *buf, u64 buf_sz)
{
return 0;
--
2.25.1
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
next prev parent reply other threads:[~2023-06-20 10:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 9:59 [Intel-wired-lan] [PATCH iwl-next V1 00/15] Add E800 live migration driver Lingyu Liu
2023-06-20 9:59 ` [Intel-wired-lan] [PATCH iwl-next V1 01/15] ice: Fix missing legacy 32byte RXDID in the supported bitmap Lingyu Liu
2023-06-20 11:05 ` Przemek Kitszel
2023-06-21 9:16 ` Liu, Lingyu
2023-06-20 9:59 ` [Intel-wired-lan] [PATCH iwl-next V1 02/15] ice: add function to get rxq context Lingyu Liu
2023-06-20 9:59 ` [Intel-wired-lan] [PATCH iwl-next V1 03/15] ice: check VF migration status before sending messages to VF Lingyu Liu
2023-06-20 9:59 ` [Intel-wired-lan] [PATCH iwl-next V1 04/15] ice: add migration init field and helper functions Lingyu Liu
2023-06-20 9:59 ` [Intel-wired-lan] [PATCH iwl-next V1 05/15] ice: save VF messages as device state Lingyu Liu
2023-06-20 9:59 ` [Intel-wired-lan] [PATCH iwl-next V1 06/15] ice: save and restore " Lingyu Liu
2023-06-20 9:59 ` [Intel-wired-lan] [PATCH iwl-next V1 07/15] ice: do not notify VF link state during migration Lingyu Liu
2023-06-20 9:59 ` [Intel-wired-lan] [PATCH iwl-next V1 08/15] ice: change VSI id in virtual channel message after migration Lingyu Liu
2023-06-20 9:59 ` [Intel-wired-lan] [PATCH iwl-next V1 09/15] ice: save and restore RX queue head Lingyu Liu
2023-06-20 9:59 ` [Intel-wired-lan] [PATCH iwl-next V1 10/15] ice: save and restore TX " Lingyu Liu
2023-06-20 9:59 ` Lingyu Liu [this message]
2023-06-20 9:59 ` [Intel-wired-lan] [PATCH iwl-next V1 12/15] ice: mask VF advanced capabilities if live migration is activated Lingyu Liu
2023-06-20 9:59 ` [Intel-wired-lan] [PATCH iwl-next V1 13/15] vfio/ice: implement vfio_pci driver for E800 devices Lingyu Liu
2023-06-20 10:00 ` [Intel-wired-lan] [PATCH iwl-next V1 14/15] vfio: Expose vfio_device_has_container() Lingyu Liu
2023-06-20 10:00 ` [Intel-wired-lan] [PATCH iwl-next V1 15/15] vfio/ice: support iommufd vfio compat mode Lingyu Liu
2023-06-20 11:08 ` [Intel-wired-lan] [PATCH iwl-next V1 00/15] Add E800 live migration driver Paul Menzel
2023-06-27 9:06 ` Liu, Lingyu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230620100001.5331-12-lingyu.liu@intel.com \
--to=lingyu.liu@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kevin.tian@intel.com \
--cc=phani.r.burra@intel.com \
--cc=yi.l.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox