vdpa/snet: support [s/g]et_vq_state and suspend
Subsystems (2)
Alvaro Karsz
reviewercover vdpa/snet: support [s/g]et_vq_state and suspend
Add more vDPA callbacks.
[s/g]et_vq_state is added in patch 1, including a new control mechanism to read data from the DPU.
suspend is added in patch 2.
Alvaro Karsz (2):
vdpa/snet: support getting and setting VQ state
vdpa/snet: support the suspend vDPA callback
drivers/vdpa/solidrun/Makefile | 1 + drivers/vdpa/solidrun/snet_ctrl.c | 324 +++++++++++++++++++++++++++++ drivers/vdpa/solidrun/snet_hwmon.c | 2 +- drivers/vdpa/solidrun/snet_main.c | 126 ++++++----- drivers/vdpa/solidrun/snet_vdpa.h | 18 +- 5 files changed, 400 insertions(+), 71 deletions(-) create mode 100644 drivers/vdpa/solidrun/snet_ctrl.c
Signature · 6 lines
2.34.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Alvaro Karsz
reviewerPATCH 1/2 vdpa/snet: support getting and setting VQ state
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.
--- drivers/vdpa/solidrun/Makefile | 1 + drivers/vdpa/solidrun/snet_ctrl.c | 318 +++++++++++++++++++++++++++++ drivers/vdpa/solidrun/snet_hwmon.c | 2 +- drivers/vdpa/solidrun/snet_main.c | 111 ++++------ drivers/vdpa/solidrun/snet_vdpa.h | 17 +- 5 files changed, 378 insertions(+), 71 deletions(-) create mode 100644 drivers/vdpa/solidrun/snet_ctrl.c
drivers/vdpa/solidrun/Makefile +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_SNET_VDPA) += snet_vdpa.o snet_vdpa-$(CONFIG_SNET_VDPA) += snet_main.o +snet_vdpa-$(CONFIG_SNET_VDPA) += snet_ctrl.o ifdef CONFIG_HWMON snet_vdpa-$(CONFIG_SNET_VDPA) += snet_hwmon.o endif
drivers/vdpa/solidrun/snet_ctrl.c new file +318 -0
318 lines not on this page · raw message
drivers/vdpa/solidrun/snet_hwmon.c +1 -1
@@ -2,7 +2,7 @@/* * SolidRun DPU driver for control plane * -* Copyright (C) 2022 SolidRun +* Copyright (C) 2022-2023 SolidRun * * Author: Alvaro Karsz <[email protected]> *
drivers/vdpa/solidrun/snet_main.c +44 -67
208 lines not on this page · raw message
drivers/vdpa/solidrun/snet_vdpa.h +14 -3
@@ -2,7 +2,7 @@/* * SolidRun DPU driver for control plane * -* Copyright (C) 2022 SolidRun +* Copyright (C) 2022-2023 SolidRun * * Author: Alvaro Karsz <[email protected]> *
@@ -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;/* desc base address */ u64 desc_area;/* device base address */
@@ -51,6 +56,8 @@ struct snet {struct vdpa_device vdpa;/* Config callback */ struct vdpa_callback cb; +/* To lock the control mechanism */ +struct mutex ctrl_lock;/* array of virqueues */ struct snet_vq **vqs;/* Used features */
@@ -117,8 +124,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 +198,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_
Signature · 6 lines
2.34.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Alvaro Karsz
reviewerPATCH 2/2 vdpa/snet: support the suspend vDPA callback
In reply to Alvaro KarszWhen suspend is called, the driver sends a suspend command to the DPU through the control mechanism.
--- drivers/vdpa/solidrun/snet_ctrl.c | 6 ++++++ drivers/vdpa/solidrun/snet_main.c | 15 +++++++++++++++ drivers/vdpa/solidrun/snet_vdpa.h | 1 + 3 files changed, 22 insertions(+)
drivers/vdpa/solidrun/snet_ctrl.c +6 -0
@@ -15,6 +15,7 @@enum snet_ctrl_opcodes {SNET_CTRL_OP_DESTROY =1 ,SNET_CTRL_OP_READ_VQ_STATE , +SNET_CTRL_OP_SUSPEND , };#define SNET_CTRL_TIMEOUT 2000000
@@ -316,3 +317,8 @@ int snet_read_vq_state(struct snet *snet, u16 idx, struct vdpa_vq_state *state)return snet_ctrl_read_from_dpu (snet,SNET_CTRL_OP_READ_VQ_STATE , idx, state,sizeof (*state)); } + +int snet_suspend_dev (struct snet *snet) +{ +return snet_send_ctrl_msg (snet,SNET_CTRL_OP_SUSPEND ,0 ); +}
drivers/vdpa/solidrun/snet_main.c +15 -0
@@ -483,6 +483,20 @@ static void snet_set_config(struct vdpa_device *vdev, unsigned int offset,iowrite8 (*buf_ptr++, cfg_ptr + i); } +static int snet_suspend (struct vdpa_device *vdev) +{ +struct snet *snet =vdpa_to_snet (vdev); +int ret; + + ret =snet_suspend_dev (snet); +if (ret) +SNET_ERR (snet->pdev,"SNET[%u] suspend failed, err: %d\n" , snet->sid, ret); +else +SNET_DBG (snet->pdev,"Suspend SNET[%u] device\n" , snet->sid); + +return ret; +} +static const struct vdpa_config_ops snet_config_ops = { .set_vq_address = snet_set_vq_address, .set_vq_num = snet_set_vq_num,
@@ -508,6 +522,7 @@ static const struct vdpa_config_ops snet_config_ops = { .set_status = snet_set_status, .get_config = snet_get_config, .set_config = snet_set_config, + .suspend = snet_suspend, };static int psnet_open_pf_bar (struct pci_dev *pdev,struct psnet *psnet)
drivers/vdpa/solidrun/snet_vdpa.h +1 -0
@@ -201,5 +201,6 @@ void psnet_create_hwmon(struct pci_dev *pdev);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); +int snet_suspend_dev (struct snet *snet);#endif //_SNET_VDPA_H_
Signature · 6 lines
2.34.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Alvaro Karsz
reviewerping
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Michael S. Tsirkin
maintainerQuoted 1 line · Alvaro Karsz
ping
tagged. in the future pls CC everyone on the cover letter too.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Alvaro Karsz
reviewerQuoted 1 line
tagged. in the future pls CC everyone on the cover letter too.
Ok, thanks.
I'm not getting responses, should I resend it?
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Michael S. Tsirkin
maintainerQuoted 5 lines · Alvaro Karsz
Quoted 1 line
tagged. in the future pls CC everyone on the cover letter too.
Ok, thanks.
I'm not getting responses, should I resend it?
Hmm maybe. Remember to add "PATCH resend" in the subject. git format-patch has a --subject-prefix for this.
Signature · 6 lines
MST _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization