Re: [PATCH v3 1/2] vdpa/snet: support getting and setting VQ state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




在 2023/4/10 18:02, Alvaro Karsz 写道:
This patch adds the get_vq_state and set_vq_state vDPA callbacks.

In order to get the VQ state, the state needs to be read from the DPU.
In order to allow that, the old messaging mechanism is replaced with a new,
flexible control mechanism.
This mechanism allows to read data from the DPU.

The mechanism can be used if the negotiated config version is 2 or
higher.

If the new mechanism is used when the config version is 1, it will call
snet_send_ctrl_msg_old, which is config 1 compatible.

Signed-off-by: Alvaro Karsz <alvaro.karsz@xxxxxxxxxxxxx>
---
  drivers/vdpa/solidrun/Makefile     |   1 +
  drivers/vdpa/solidrun/snet_ctrl.c  | 323 +++++++++++++++++++++++++++++
  drivers/vdpa/solidrun/snet_hwmon.c |   2 +-
  drivers/vdpa/solidrun/snet_main.c  | 112 ++++------
  drivers/vdpa/solidrun/snet_vdpa.h  |  19 +-
  5 files changed, 386 insertions(+), 71 deletions(-)
  create mode 100644 drivers/vdpa/solidrun/snet_ctrl.c


[...]


@@ -20,10 +20,15 @@
  #define SNET_INFO(pdev, fmt, ...) dev_info(&(pdev)->dev, "%s"fmt, "snet_vdpa: ", ##__VA_ARGS__)
  #define SNET_DBG(pdev, fmt, ...) dev_dbg(&(pdev)->dev, "%s"fmt, "snet_vdpa: ", ##__VA_ARGS__)
  #define SNET_HAS_FEATURE(s, f) ((s)->negotiated_features & BIT_ULL(f))
+/* Check if negotiated config version is at least @ver */
+#define SNET_CFG_VER(snet, ver) ((snet)->psnet->negotiated_cfg_ver >= (ver))
+
  /* VQ struct */
  struct snet_vq {
  	/* VQ callback */
  	struct vdpa_callback cb;
+	/* VQ initial state */
+	struct vdpa_vq_state inital_state;


I guess you meant "initial_state" really here.

Btw, who is used to initialize initial_state (especially the case for packed ring)?

In snet_set_vq_state(), only the value that is set by bus is checked but not the inital_state.

Thanks


  	/* desc base address */
  	u64 desc_area;
  	/* device base address */
@@ -51,6 +56,10 @@ struct snet {
  	struct vdpa_device vdpa;
  	/* Config callback */
  	struct vdpa_callback cb;
+	/* To lock the control mechanism */
+	struct mutex ctrl_lock;
+	/* Spinlock to protect critical parts in the control mechanism */
+	spinlock_t ctrl_spinlock;
  	/* array of virqueues */
  	struct snet_vq **vqs;
  	/* Used features */
@@ -117,8 +126,8 @@ struct snet_cfg {
  	u32 kick_off;
  	/* Offset in PCI BAR for HW monitoring */
  	u32 hwmon_off;
-	/* Offset in PCI BAR for SNET messages */
-	u32 msg_off;
+	/* Offset in PCI BAR for Control mechanism */
+	u32 ctrl_off;
  	/* Config general flags - enum snet_cfg_flags */
  	u32 flags;
  	/* Reserved for future usage */
@@ -191,4 +200,8 @@ static inline void snet_write64(struct snet *snet, u32 off, u64 val)
  void psnet_create_hwmon(struct pci_dev *pdev);
  #endif
+void snet_ctrl_clear(struct snet *snet);
+int snet_destroy_dev(struct snet *snet);
+int snet_read_vq_state(struct snet *snet, u16 idx, struct vdpa_vq_state *state);
+
  #endif //_SNET_VDPA_H_

_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization




[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux