Re: [PATCH] MAINTAINERS: Update maintainer list for virtio i2c

2022-12-13 Thread Viresh Kumar
On 14-12-22, 13:36, Conghui wrote:
> This updates the maintainer for virtio i2c drvier
> 
> Signed-off-by: Conghui 
> Acked-by: Jian Jun Chen 
> ---
>  MAINTAINERS | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index a8c8f6b42436..44747f4641a6 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -21920,7 +21920,7 @@ F:include/uapi/linux/virtio_snd.h
>  F:   sound/virtio/*
>  
>  VIRTIO I2C DRIVER
> -M:   Conghui Chen 
> +M:   Jian Jun Chen 
>  M:   Viresh Kumar 
>  L:   linux-...@vger.kernel.org
>  L:   virtualization@lists.linux-foundation.org

Wolfram,

I understand that it is okay to pass the maintainership, within the
company, for platform specific parts from one person to another, since
they have the best knowledge of the code and are the only one
interested in maintaining it too.

But what is the rule for generic drivers like this one ?

-- 
viresh
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH] vdpa_sim_net: should not drop the multicast/broadcast packet

2022-12-13 Thread Jason Wang
On Wed, Dec 14, 2022 at 1:43 PM Cindy Lu  wrote:
>
> In the receive_filter(), should not drop the packet with the
> broadcast/multicast address. Add the check for this
>
> Signed-off-by: Cindy Lu 

Acked-by: Jason Wang 

Thanks

> ---
>  drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c 
> b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
> index c3cb225ea469..0f4739c31eea 100644
> --- a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
> +++ b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
> @@ -62,6 +62,9 @@ static bool receive_filter(struct vdpasim *vdpasim, size_t 
> len)
> if (len < ETH_ALEN + hdr_len)
> return false;
>
> +   if (is_broadcast_ether_addr(vdpasim->buffer + hdr_len) ||
> +   is_multicast_ether_addr(vdpasim->buffer + hdr_len))
> +   return true;
> if (!strncmp(vdpasim->buffer + hdr_len, vio_config->mac, ETH_ALEN))
> return true;
>
> --
> 2.34.3
>

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH net-next v6] virtio/vsock: replace virtio_vsock_pkt with sk_buff

2022-12-13 Thread Stefano Garzarella

On Tue, Dec 13, 2022 at 10:06:23AM -0500, Michael S. Tsirkin wrote:

On Tue, Dec 13, 2022 at 11:22:32AM +0100, Stefano Garzarella wrote:

> +  if (len <= GOOD_COPY_LEN && !skb_queue_empty_lockless(>rx_queue)) {

Same here.

If there are no major changes to be made, I think the next version is the
final ones, though we are now in the merge window, so net-next is closed
[1], only RFCs can be sent [2].

I suggest you wait until the merge window is over (two weeks usually) to
send the next version.


Nah, you never know, could be more comments. And depending on the timing
I might be able to merge it.


Right, in the end these changes are only to virtio-vsock transport, so 
they can go smoothly even with your tree.


@Bobby, so if you can fix the remaining small things, we can try to 
merge it :-)


Thanks,
Stefano

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATH v2 0/8] vdpa/mlx5: Add debugfs subtree and fixes

2022-12-13 Thread Michael S. Tsirkin
Yes it's all going into the next pull, thanks!

On Tue, Dec 13, 2022 at 07:33:08AM +, Eli Cohen wrote:
> Michael?
> 
> > -Original Message-
> > From: Eli Cohen
> > Sent: Thursday, 24 November 2022 8:34
> > To: m...@redhat.com; jasow...@redhat.com; linux-ker...@vger.kernel.org;
> > virtualization@lists.linux-foundation.org
> > Cc: si-wei@oracle.com; epere...@redhat.com; l...@redhat.com
> > Subject: RE: [PATH v2 0/8] vdpa/mlx5: Add debugfs subtree and fixes
> > 
> > Hi Michael,
> > 
> > Are you going to pull this series? It has been reviewed.
> > 
> > 
> > > -Original Message-
> > > From: Eli Cohen 
> > > Sent: Monday, 14 November 2022 15:18
> > > To: m...@redhat.com; jasow...@redhat.com; linux-
> > ker...@vger.kernel.org;
> > > virtualization@lists.linux-foundation.org
> > > Cc: si-wei@oracle.com; epere...@redhat.com; l...@redhat.com; Eli
> > > Cohen 
> > > Subject: [PATH v2 0/8] vdpa/mlx5: Add debugfs subtree and fixes
> > >
> > > This series is a resend of previously sent patch list. It adds a few
> > > fixes so I treat as a v0 of a new series.
> > >
> > > It adds a kernel config param CONFIG_MLX5_VDPA_STEERING_DEBUG
> > that
> > > when
> > > eabled allows to read rx unicast and multicast counters per tagged or
> > untagged
> > > traffic.
> > >
> > > Examples:
> > > $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-
> > > 0/rx/untagged/mcast/packets
> > > $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-
> > 0/rx/untagged/ucast/bytes
> > >
> > > v1->v2:
> > > 1. Reorder patches so fixes are first
> > > 2. Break "Fix rule forwarding VLAN to TIR" into two patches
> > > 3. Squash fix for bug in first patch from "Add RX counters to debugfs"
> > > 4. Move clearing of nb_registered before calling 
> > > mlx5_notifier_unregister()
> > in
> > > mlx5_vdpa_dev_del()
> > >
> > >
> > > Eli Cohen (8):
> > >   vdpa/mlx5: Fix rule forwarding VLAN to TIR
> > >   vdpa/mlx5: Return error on vlan ctrl commands if not supported
> > >   vdpa/mlx5: Fix wrong mac address deletion
> > >   vdpa/mlx5: Avoid using reslock in event_handler
> > >   vdpa/mlx5: Avoid overwriting CVQ iotlb
> > >   vdpa/mlx5: Move some definitions to a new header file
> > >   vdpa/mlx5: Add debugfs subtree
> > >   vdpa/mlx5: Add RX counters to debugfs
> > >
> > >  drivers/vdpa/Kconfig   |  12 ++
> > >  drivers/vdpa/mlx5/Makefile |   2 +-
> > >  drivers/vdpa/mlx5/core/mlx5_vdpa.h |   5 +-
> > >  drivers/vdpa/mlx5/core/mr.c|  44 ++---
> > >  drivers/vdpa/mlx5/net/debug.c  | 152 ++
> > >  drivers/vdpa/mlx5/net/mlx5_vnet.c  | 250 ++---
> > >  drivers/vdpa/mlx5/net/mlx5_vnet.h  |  94 +++
> > >  7 files changed, 412 insertions(+), 147 deletions(-)
> > >  create mode 100644 drivers/vdpa/mlx5/net/debug.c
> > >  create mode 100644 drivers/vdpa/mlx5/net/mlx5_vnet.h
> > >
> > > --
> > > 2.38.1
> 

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH] vdpa: conditionally fill max max queue pair for stats

2022-12-13 Thread Michael S. Tsirkin
On Tue, Dec 13, 2022 at 03:12:23PM +0800, Jason Wang wrote:
> On Wed, Sep 7, 2022 at 4:11 PM Eli Cohen  wrote:
> >
> > > From: Jason Wang 
> > > Sent: Wednesday, 7 September 2022 9:53
> > > To: Eli Cohen 
> > > Cc: m...@redhat.com; virtualization@lists.linux-foundation.org; linux-
> > > ker...@vger.kernel.org
> > > Subject: Re: [PATCH] vdpa: conditionally fill max max queue pair for stats
> > >
> > > On Wed, Sep 7, 2022 at 2:11 PM Eli Cohen  wrote:
> > > >
> > > > > From: Jason Wang 
> > > > > Sent: Wednesday, 7 September 2022 9:01
> > > > > To: m...@redhat.com; jasow...@redhat.com; Eli Cohen
> > > ;
> > > > > virtualization@lists.linux-foundation.org; 
> > > > > linux-ker...@vger.kernel.org
> > > > > Subject: [PATCH] vdpa: conditionally fill max max queue pair for stats
> > > > >
> > > > > For the device without multiqueue feature, we will read 0 as
> > > > > max_virtqueue_pairs from the config.
> > > > If this is the case for other vdpa vendor drivers, shouldn't we fix it 
> > > > there?
> > > After all,
> > > > config->max_virtqueue_pairs should always show valid values.
> > >
> > > Not for the case when the device doesn't offer MQ. According to the
> > > spec, the max_virtqueue_pairs doesn't exist in this case.
> > >
> > I see, thanks.
> >
> > > >
> > > > > So if we fill
> > > > > VDPA_ATTR_DEV_NET_CFG_MAX_VQP with the value we read from the
> > > > > config
> > > > > we will confuse the user.
> > > > >
> > > > > Fixing this by only filling the value when multiqueue is offered by
> > > > > the device so userspace can assume 1 when the attr is not provided.
> > > > >
> > > > > Fixes: 13b00b135665c("vdpa: Add support for querying vendor
> > > statistics")
> > > > > Cc: Eli Cohen 
> > > > > Signed-off-by: Jason Wang 
> > > > > ---
> > > > >  drivers/vdpa/vdpa.c | 9 -
> > > > >  1 file changed, 4 insertions(+), 5 deletions(-)
> > > > >
> > > > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> > > > > index c06c02704461..bc328197263f 100644
> > > > > --- a/drivers/vdpa/vdpa.c
> > > > > +++ b/drivers/vdpa/vdpa.c
> > > > > @@ -894,7 +894,6 @@ static int vdpa_fill_stats_rec(struct vdpa_device
> > > > > *vdev, struct sk_buff *msg,
> > > > >  {
> > > > >   struct virtio_net_config config = {};
> > > > >   u64 features;
> > > > > - u16 max_vqp;
> > > > >   u8 status;
> > > > >   int err;
> > > > >
> > > > > @@ -905,15 +904,15 @@ static int vdpa_fill_stats_rec(struct
> > > vdpa_device
> > > > > *vdev, struct sk_buff *msg,
> > > > >   }
> > > > >   vdpa_get_config_unlocked(vdev, 0, , sizeof(config));
> > > > >
> > > > > - max_vqp = __virtio16_to_cpu(true, config.max_virtqueue_pairs);
> > > > > - if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP,
> > > > > max_vqp))
> > > > > - return -EMSGSIZE;
> > > > > -
> > > > >   features = vdev->config->get_driver_features(vdev);
> > > > >   if (nla_put_u64_64bit(msg,
> > > > > VDPA_ATTR_DEV_NEGOTIATED_FEATURES,
> > > > > features, VDPA_ATTR_PAD))
> > > > >   return -EMSGSIZE;
> > > > >
> > > > > + err = vdpa_dev_net_mq_config_fill(vdev, msg, features, );
> > > > > + if (err)
> > > > > + return err;
> > > > > +
> > > >
> > > > So that means that you can't read statistics when MQ is not supported. 
> > > > Is
> > > this worth sacrificing?
> > >
> > > vdpa_dev_net_mq_config_fill() will return 0 in the case of !MQ, so it
> > > should still work.
> >
> > Right, missed that.
> >
> > Reviewed-by: Eli Cohen 
> 
> Michael, I don't see this is merged.
> 
> Any comments for this patch?
> 
> Thanks
> 

Will be in the pull. Working on it now, it's pretty big.

> >
> > >
> > > Thanks
> > >
> > >
> > > >
> > > > >   if (nla_put_u32(msg, VDPA_ATTR_DEV_QUEUE_INDEX, index))
> > > > >   return -EMSGSIZE;
> > > > >
> > > > > --
> > > > > 2.25.1
> > > >
> >

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH net] virtio-net: correctly enable callback during start_xmit

2022-12-13 Thread Michael S. Tsirkin
On Tue, Dec 13, 2022 at 02:57:54PM +0800, Jason Wang wrote:
> On Tue, Dec 13, 2022 at 2:38 PM Michael S. Tsirkin  wrote:
> >
> > On Tue, Dec 13, 2022 at 11:43:36AM +0800, Jason Wang wrote:
> > > On Tue, Dec 13, 2022 at 11:38 AM Xuan Zhuo  
> > > wrote:
> > > >
> > > > On Mon, 12 Dec 2022 04:25:22 -0500, "Michael S. Tsirkin" 
> > > >  wrote:
> > > > > On Mon, Dec 12, 2022 at 05:10:29PM +0800, Jason Wang wrote:
> > > > > > Commit a7766ef18b33("virtio_net: disable cb aggressively") enables
> > > > > > virtqueue callback via the following statement:
> > > > > >
> > > > > > do {
> > > > > >..
> > > > > > } while (use_napi && kick &&
> > > > > >unlikely(!virtqueue_enable_cb_delayed(sq->vq)));
> > > > > >
> > > > > > This will cause a missing call to virtqueue_enable_cb_delayed() when
> > > > > > kick is false. Fixing this by removing the checking of the kick from
> > > > > > the condition to make sure callback is enabled correctly.
> > > > > >
> > > > > > Fixes: a7766ef18b33 ("virtio_net: disable cb aggressively")
> > > > > > Signed-off-by: Jason Wang 
> > > > > > ---
> > > > > > The patch is needed for -stable.
> > > > >
> > > > > stable rules don't allow for theoretical fixes. Was a problem 
> > > > > observed?
> > >
> > > Yes, running a pktgen sample script can lead to a tx timeout.
> >
> > Since April 2021 and we only noticed now? Are you sure it's the
> > right Fixes tag?
> 
> Well, reverting a7766ef18b33 makes pktgen work again.
> 
> The reason we doesn't notice is probably because:
> 
> 1) We don't support BQL, so no bulk dequeuing (skb list) in normal traffic
> 2) When burst is enabled for pktgen, it can do bulk xmit via skb list by its 
> own
> 
> >
> > > > >
> > > > > > ---
> > > > > >  drivers/net/virtio_net.c | 4 ++--
> > > > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > > >
> > > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > > > > > index 86e52454b5b5..44d7daf0267b 100644
> > > > > > --- a/drivers/net/virtio_net.c
> > > > > > +++ b/drivers/net/virtio_net.c
> > > > > > @@ -1834,8 +1834,8 @@ static netdev_tx_t start_xmit(struct sk_buff 
> > > > > > *skb, struct net_device *dev)
> > > > > >
> > > > > > free_old_xmit_skbs(sq, false);
> > > > > >
> > > > > > -   } while (use_napi && kick &&
> > > > > > -  unlikely(!virtqueue_enable_cb_delayed(sq->vq)));
> > > > > > +   } while (use_napi &&
> > > > > > +unlikely(!virtqueue_enable_cb_delayed(sq->vq)));
> > > > > >
> > > > >
> > > > > A bit more explanation pls.  kick simply means !netdev_xmit_more -
> > > > > if it's false we know there will be another packet, then transmissing
> > > > > that packet will invoke virtqueue_enable_cb_delayed. No?
> > > >
> > > > It's just that there may be a next packet, but in fact there may not be.
> > > > For example, the vq is full, and the driver stops the queue.
> > >
> > > Exactly, when the queue is about to be full we disable tx and wait for
> > > the next tx interrupt to re-enable tx.
> > >
> > > Thanks
> >
> > OK, it's a good idea to document that.
> 
> Will do.
> 
> > And we should enable callbacks at that point, not here on data path.
> 
> I'm not sure I understand here. Are you suggesting removing the
> !user_napi check here?
> 
> if (!use_napi &&
> unlikely(!virtqueue_enable_cb_delayed(sq->vq))) {
> /* More just got used, free them then recheck. */
> free_old_xmit_skbs(sq, false);
> if (sq->vq->num_free >= 2+MAX_SKB_FRAGS) {
> netif_start_subqueue(dev, qnum);
> virtqueue_disable_cb(sq->vq);
> }
> }


At least, I suggest calling virtqueue_enable_cb_delayed around
this area of code. I have not really thought all this path through
and how all the corner cases interact.



> Btw, it doesn't differ too much as kick is always true without pktgen
> and that may even need more comments or make the code even harder to
> read. We need a patch for -stable at least so I prefer to let this
> patch go first and do optimization on top.
> 
> Thanks

There's a chance of perf regression here too.  Let's write the full
patch first of all. If you want to make it a 2 patch series that is fine
but it is here since 2021 I don't see why we should rush a fix. Worry
about backporting later.

> >
> >
> > > >
> > > > Thanks.
> > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > > /* timestamp packet in software */
> > > > > > skb_tx_timestamp(skb);
> > > > > > --
> > > > > > 2.25.1
> > > > >
> > > > > ___
> > > > > Virtualization mailing list
> > > > > Virtualization@lists.linux-foundation.org
> > > > > https://lists.linuxfoundation.org/mailman/listinfo/virtualization
> > > >
> >

___
Virtualization 

Re: [PATCH net-next v6] virtio/vsock: replace virtio_vsock_pkt with sk_buff

2022-12-13 Thread Michael S. Tsirkin
On Tue, Dec 13, 2022 at 11:22:32AM +0100, Stefano Garzarella wrote:
> > +   if (len <= GOOD_COPY_LEN && !skb_queue_empty_lockless(>rx_queue)) {
> 
> Same here.
> 
> If there are no major changes to be made, I think the next version is the
> final ones, though we are now in the merge window, so net-next is closed
> [1], only RFCs can be sent [2].
> 
> I suggest you wait until the merge window is over (two weeks usually) to
> send the next version.

Nah, you never know, could be more comments. And depending on the timing
I might be able to merge it.

-- 
MST

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [RFC PATCH v4 4/4] test/vsock: vsock_perf utility

2022-12-13 Thread Stefano Garzarella

On Tue, Dec 06, 2022 at 08:54:28PM +, Arseniy Krasnov wrote:

This adds utility to check vsock rx/tx performance.

Usage as sender:
./vsock_perf --sender  --port  --bytes 

Little typo "". I mean replace `)` with `>`


Usage as receiver:
./vsock_perf --port  --rcvlowat 

Signed-off-by: Arseniy Krasnov 
---
tools/testing/vsock/Makefile |   3 +-
tools/testing/vsock/README   |  34 +++
tools/testing/vsock/vsock_perf.c | 434 +++
3 files changed, 470 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/vsock/vsock_perf.c

diff --git a/tools/testing/vsock/Makefile b/tools/testing/vsock/Makefile
index f8293c6910c9..43a254f0e14d 100644
--- a/tools/testing/vsock/Makefile
+++ b/tools/testing/vsock/Makefile
@@ -1,8 +1,9 @@
# SPDX-License-Identifier: GPL-2.0-only
-all: test
+all: test vsock_perf
test: vsock_test vsock_diag_test
vsock_test: vsock_test.o timeout.o control.o util.o
vsock_diag_test: vsock_diag_test.o timeout.o control.o util.o
+vsock_perf: vsock_perf.o

CFLAGS += -g -O2 -Werror -Wall -I. -I../../include -I../../../usr/include 
-Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD 
-U_FORTIFY_SOURCE -D_GNU_SOURCE
.PHONY: all test clean
diff --git a/tools/testing/vsock/README b/tools/testing/vsock/README
index 4d5045e7d2c3..e6f6735bba05 100644
--- a/tools/testing/vsock/README
+++ b/tools/testing/vsock/README
@@ -35,3 +35,37 @@ Invoke test binaries in both directions as follows:
   --control-port=$GUEST_IP \
   --control-port=1234 \
   --peer-cid=3
+
+vsock_perf utility
+---
+'vsock_perf' is a simple tool to measure vsock performance. It works in
+sender/receiver modes: sender connect to peer at the specified port and
+starts data transmission to the receiver. After data processing is done,
+it prints several metrics(see below).
+
+Usage:
+# run as sender
+# connect to CID 2, port 1234, send 1G of data, tx buf size is 1M
+./vsock_perf --sender 2 --port 1234 --bytes 1G --buf-size 1M
+
+Output:
+tx performance: A Gb/s
+
+Output explanation:
+A is calculated as "number of bytes to send" / "time in tx loop"
+
+# run as receiver
+# listen port 1234, rx buf size is 1M, socket buf size is 1G, SO_RCVLOWAT is 
64K
+./vsock_perf --port 1234 --buf-size 1M --vsk-size 1G --rcvlowat 64K
+
+Output:
+rx performance: A Gb/s
+total in 'read()': B sec
+POLLIN wakeups: C
+average in 'read()': D ns
+
+Output explanation:
+A is calculated as "number of received bytes" / "time in rx loop".
+B is time, spent in 'read()' system call(excluding 'poll()')
+C is number of 'poll()' wake ups with POLLIN bit set.
+D is B / C, e.g. average amount of time, spent in single 'read()'.
diff --git a/tools/testing/vsock/vsock_perf.c b/tools/testing/vsock/vsock_perf.c
new file mode 100644
index ..248fc3285d5c
--- /dev/null
+++ b/tools/testing/vsock/vsock_perf.c
@@ -0,0 +1,434 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * vsock_perf - benchmark utility for vsock.
+ *
+ * Copyright (C) 2022 SberDevices.
+ *
+ * Author: Arseniy Krasnov 
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DEFAULT_BUF_SIZE_BYTES (128 * 1024)
+#define DEFAULT_TO_SEND_BYTES  (64 * 1024)
+#define DEFAULT_VSOCK_BUF_BYTES (256 * 1024)
+#define DEFAULT_RCVLOWAT_BYTES 1
+#define DEFAULT_PORT   1234
+
+#define BYTES_PER_GB   (1024 * 1024 * 1024ULL)
+#define NSEC_PER_SEC   (10ULL)
+
+static unsigned int port = DEFAULT_PORT;
+static unsigned long buf_size_bytes = DEFAULT_BUF_SIZE_BYTES;
+static unsigned long vsock_buf_bytes = DEFAULT_VSOCK_BUF_BYTES;
+
+static inline time_t current_nsec(void)
+{
+   struct timespec ts;
+
+   if (clock_gettime(CLOCK_REALTIME, )) {
+   perror("clock_gettime");
+   exit(EXIT_FAILURE);
+   }
+
+   return (ts.tv_sec * NSEC_PER_SEC) + ts.tv_nsec;
+}
+
+/* From lib/cmdline.c. */
+static unsigned long memparse(const char *ptr)
+{
+   char *endptr;
+
+   unsigned long long ret = strtoull(ptr, , 0);
+
+   switch (*endptr) {
+   case 'E':
+   case 'e':
+   ret <<= 10;
+   case 'P':
+   case 'p':
+   ret <<= 10;
+   case 'T':
+   case 't':
+   ret <<= 10;
+   case 'G':
+   case 'g':
+   ret <<= 10;
+   case 'M':
+   case 'm':
+   ret <<= 10;
+   case 'K':
+   case 'k':
+   ret <<= 10;
+   endptr++;
+   default:
+   break;
+   }
+
+   return ret;
+}
+
+static void vsock_increase_buf_size(int fd)
+{
+   if (setsockopt(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_MAX_SIZE,
+  _buf_bytes, sizeof(vsock_buf_bytes))) {
+   perror("setsockopt(SO_VM_SOCKETS_BUFFER_MAX_SIZE)");
+   exit(EXIT_FAILURE);
+   }
+
+   if 

Re: [RFC PATCH v4 2/4] test/vsock: rework message bounds test

2022-12-13 Thread Stefano Garzarella

On Tue, Dec 06, 2022 at 08:50:55PM +, Arseniy Krasnov wrote:

This updates message bound test making it more complex. Instead of
sending 1 bytes messages with one MSG_EOR bit, it sends messages of
random length(one half of messages are smaller than page size, second
half are bigger) with random number of MSG_EOR bits set. Receiver
also don't know total number of messages.

Signed-off-by: Arseniy Krasnov 
---
tools/testing/vsock/control.c|  28 +++
tools/testing/vsock/control.h|   2 +
tools/testing/vsock/util.c   |  13 
tools/testing/vsock/util.h   |   1 +
tools/testing/vsock/vsock_test.c | 128 +++
5 files changed, 157 insertions(+), 15 deletions(-)


Reviewed-by: Stefano Garzarella 

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [RFC PATCH v4 1/4] vsock: return errors other than -ENOMEM to socket

2022-12-13 Thread Stefano Garzarella

On Tue, Dec 06, 2022 at 08:49:19PM +, Arseniy Krasnov wrote:

From: Bobby Eshleman 

This removes behaviour, where error code returned from any transport
was always switched to ENOMEM. For example when user tries to send too
big message via SEQPACKET socket, transport layers return EMSGSIZE, but
this error code will be replaced to ENOMEM and returned to user.


Just a minor thing here, I would write
"this error code was always replaced with ENOMEM and returned to user"

To make it clearer that it was the previous behavior.

Anyway, the patch LGTM:

Reviewed-by: Stefano Garzarella 



Signed-off-by: Bobby Eshleman 
Signed-off-by: Arseniy Krasnov 
---
net/vmw_vsock/af_vsock.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 884eca7f6743..61ddab664c33 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1862,8 +1862,9 @@ static int vsock_connectible_sendmsg(struct socket *sock, 
struct msghdr *msg,
written = transport->stream_enqueue(vsk,
msg, len - total_written);
}
+
if (written < 0) {
-   err = -ENOMEM;
+   err = written;
goto out_err;
}

--
2.25.1


___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH net-next v6] virtio/vsock: replace virtio_vsock_pkt with sk_buff

2022-12-13 Thread Stefano Garzarella

On Tue, Dec 13, 2022 at 07:25:49AM +, Bobby Eshleman wrote:

This commit changes virtio/vsock to use sk_buff instead of
virtio_vsock_pkt. Beyond better conforming to other net code, using
sk_buff allows vsock to use sk_buff-dependent features in the future
(such as sockmap) and improves throughput.

This patch introduces the following performance changes:

Tool/Config: uperf w/ 64 threads, SOCK_STREAM
Test Runs: 5, mean of results
Before: commit 95ec6bce2a0b ("Merge branch 'net-ipa-more-endpoints'")

Test: 64KB, g2h
Before: 21.63 Gb/s
After: 25.59 Gb/s (+18%)

Test: 16B, g2h
Before: 11.86 Mb/s
After: 17.41 Mb/s (+46%)

Test: 64KB, h2g
Before: 2.15 Gb/s
After: 3.6 Gb/s (+67%)

Test: 16B, h2g
Before: 14.38 Mb/s
After: 18.43 Mb/s (+28%)

Signed-off-by: Bobby Eshleman 
---

Note: v6 was only tested from basic sanity checking in uperf, socat, and
the vsock_test tests in the mainline, but not the new tests from
Arseniy's test/vsock patches.


I tested with Arseniy's test/vsock patches applied and everything looks 
good!


I left just a couple of comments above based on Paolo review on v5 
related to skb_queue_empty_lockless().




Changes in v6:
- use skb->cb instead of skb->_skb_refdst
- use lock-free __skb_queue_purge for rx_queue when rx_lock held

Changes in v5:
- last_skb instead of skb: last_hdr->len = cpu_to_le32(last_skb->len)

Changes in v4:
- vdso/bits.h -> linux/bits.h
- add virtio_vsock_alloc_skb() helper
- virtio/vsock: rename buf_len -> total_len
- update last_hdr->len
- fix build_skb() for vsockmon (tested)
- add queue helpers
- use spin_{unlock/lock}_bh() instead of spin_lock()/spin_unlock()
- note: I only ran a few g2h tests to check that this change
 had no perf impact. The above data is still from patch
 v3.

Changes in v3:
- fix seqpacket bug
- use zero in vhost_add_used(..., 0) device doesn't write to buffer
- use xmas tree style declarations
- vsock_hdr() -> virtio_vsock_hdr() and other include file style fixes
- no skb merging
- save space by not using vsock_metadata
- use _skb_refdst instead of skb buffer space for flags
- use skb_pull() to keep track of read bytes instead of using an an
 extra variable 'off' in the skb buffer space
- remove unnecessary sk_allocation assignment
- do not zero hdr needlessly
- introduce virtio_transport_skb_len() because skb->len changes now
- use spin_lock() directly on queue lock instead of sk_buff_head helpers
 which use spin_lock_irqsave() (e.g., skb_dequeue)
- do not reduce buffer size to be page size divisible
- Note: the biggest performance change came from loosening the spinlock
 variation and not reducing the buffer size.

Changes in v2:
- Use alloc_skb() directly instead of sock_alloc_send_pskb() to minimize
 uAPI changes.
- Do not marshal errors to -ENOMEM for non-virtio implementations.
- No longer a part of the original series
- Some code cleanup and refactoring
- Include performance stats

drivers/vhost/vsock.c   | 213 +---
include/linux/virtio_vsock.h| 132 ++--
net/vmw_vsock/virtio_transport.c| 149 +++--
net/vmw_vsock/virtio_transport_common.c | 422 +---
net/vmw_vsock/vsock_loopback.c  |  51 +--
5 files changed, 501 insertions(+), 466 deletions(-)

drivers/vhost/vsock.c   | 213 +---
include/linux/virtio_vsock.h| 132 ++--
net/vmw_vsock/virtio_transport.c| 149 +++--
net/vmw_vsock/virtio_transport_common.c | 422 +---
net/vmw_vsock/vsock_loopback.c  |  51 +--
5 files changed, 501 insertions(+), 466 deletions(-)

diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c
index 5703775af129..2a5994b029b2 100644
--- a/drivers/vhost/vsock.c
+++ b/drivers/vhost/vsock.c
@@ -51,8 +51,7 @@ struct vhost_vsock {
struct hlist_node hash;

struct vhost_work send_pkt_work;
-   spinlock_t send_pkt_list_lock;
-   struct list_head send_pkt_list; /* host->guest pending packets */
+   struct sk_buff_head send_pkt_queue; /* host->guest pending packets */

atomic_t queued_replies;

@@ -108,40 +107,33 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock,
vhost_disable_notify(>dev, vq);

do {
-   struct virtio_vsock_pkt *pkt;
+   struct virtio_vsock_hdr *hdr;
+   size_t iov_len, payload_len;
struct iov_iter iov_iter;
+   u32 flags_to_restore = 0;
+   struct sk_buff *skb;
unsigned out, in;
size_t nbytes;
-   size_t iov_len, payload_len;
int head;
-   u32 flags_to_restore = 0;

-   spin_lock_bh(>send_pkt_list_lock);
-   if (list_empty(>send_pkt_list)) {
-   spin_unlock_bh(>send_pkt_list_lock);
+   spin_lock(>send_pkt_queue.lock);
+   skb = __skb_dequeue(>send_pkt_queue);
+   spin_unlock(>send_pkt_queue.lock);
+
+   if 

Re: [PATCH 3/3 v5] virtio: vdpa: new SolidNET DPU driver.

2022-12-13 Thread Alvaro Karsz
> +   SNET_WRN(pdev, "Can't start HWMON, CONFIG_HWMON is not 
> enabled\n");

I'm really sorry, but SNET_WRN should be SNET_WARN.
I will fix it

Alvaro
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH 3/3 v5] virtio: vdpa: new SolidNET DPU driver.

2022-12-13 Thread Alvaro Karsz
This commit includes:
 1) The driver to manage the controlplane over vDPA bus.
 2) A HW monitor device to read health values from the DPU.

Signed-off-by: Alvaro Karsz 
--
v2:
- Auto detect the BAR used for communication.
- When waiting for the DPU to write a config, wait for 5secs
  before giving up on the device.
- Return EOPNOTSUPP error code in vDPA set_vq_state callback if
  the vq state is not the same as the initial one.
- Implement a vDPA reset callback.
- Wait for an ACK when sending a message to the DPU.
- Add endianness comments on 64bit read/write functions.
- Remove the get_iova_range and free vDPA callbacks.
- Usage of managed device functions to ioremap a region.
- Call pci_set_drvdata and pci_set_master before
  vdpa_register_device.
- Create DMA isolation between the vDPA devices by using the
  chip SR-IOV feature.
  Every vDPA device gets a PCIe VF with its own DMA device.

v3:
- Validate vDPA config length while receiving the DPU's config,
  not while trying to write the vDPA config to the DPU.
- Request IRQs when vDPA status is set to
  VIRTIO_CONFIG_S_DRIVER_OK.
- Remove snet_reset_dev() from the PCI remove function for a VF.
v4:
- Get SolidRun vendor ID from pci_ids
v5:
- Remove "select HWMON" from Kconfig.
  Usage of "depends on HWMON || HWMON=n" instead and usage of
  IS_ENABLED(CONFIG_HWMON) when calling to snet hwmon functions.
  snet_hwmon.c is compiled only if CONFIG_HWMON is defined.
- Remove the  #include  from snet_hwmon.c.
- Remove the unnecessary (long) casting from snet_hwmon_read_reg.
- Remove the "_hwmon" ending from the hwmon name.
- Usage of IS_ERR macro to check if devm_hwmon_device_register_with_info
  failed.
- Replace schedule() with usleep_range() in the "hot loop" in
  psnet_detect_bar.
- Remove the logging of memory allocation failures.
- Add parenthesis to arguments in SNET_* macros.
- Prefer sizeof(*variable) instead of sizeof(struct x) when allocating
  memory.
---
 MAINTAINERS|4 +
 drivers/vdpa/Kconfig   |   10 +
 drivers/vdpa/Makefile  |1 +
 drivers/vdpa/solidrun/Makefile |6 +
 drivers/vdpa/solidrun/snet_hwmon.c |  188 +
 drivers/vdpa/solidrun/snet_main.c  |  
 drivers/vdpa/solidrun/snet_vdpa.h  |  196 +
 7 files changed, 1516 insertions(+)
 create mode 100644 drivers/vdpa/solidrun/Makefile
 create mode 100644 drivers/vdpa/solidrun/snet_hwmon.c
 create mode 100644 drivers/vdpa/solidrun/snet_main.c
 create mode 100644 drivers/vdpa/solidrun/snet_vdpa.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 046ff06ff97..ae425b3bed4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -21725,6 +21725,10 @@ IFCVF VIRTIO DATA PATH ACCELERATOR
 R: Zhu Lingshan 
 F: drivers/vdpa/ifcvf/
 
+SNET DPU VIRTIO DATA PATH ACCELERATOR
+R: Alvaro Karsz 
+F: drivers/vdpa/solidrun/
+
 VIRTIO BALLOON
 M: "Michael S. Tsirkin" 
 M: David Hildenbrand 
diff --git a/drivers/vdpa/Kconfig b/drivers/vdpa/Kconfig
index 50f45d03761..79625c7cc46 100644
--- a/drivers/vdpa/Kconfig
+++ b/drivers/vdpa/Kconfig
@@ -86,4 +86,14 @@ config ALIBABA_ENI_VDPA
  VDPA driver for Alibaba ENI (Elastic Network Interface) which is 
built upon
  virtio 0.9.5 specification.
 
+ config SNET_VDPA
+   tristate "SolidRun's vDPA driver for SolidNET"
+   depends on PCI_MSI && PCI_IOV && (HWMON || HWMON=n)
+   help
+ vDPA driver for SolidNET DPU.
+ With this driver, the VirtIO dataplane can be
+ offloaded to a SolidNET DPU.
+ This driver includes a HW monitor device that
+ reads health values from the DPU.
+
 endif # VDPA
diff --git a/drivers/vdpa/Makefile b/drivers/vdpa/Makefile
index 15665563a7f..59396ff2a31 100644
--- a/drivers/vdpa/Makefile
+++ b/drivers/vdpa/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_IFCVF)+= ifcvf/
 obj-$(CONFIG_MLX5_VDPA) += mlx5/
 obj-$(CONFIG_VP_VDPA)+= virtio_pci/
 obj-$(CONFIG_ALIBABA_ENI_VDPA) += alibaba/
+obj-$(CONFIG_SNET_VDPA) += solidrun/
diff --git a/drivers/vdpa/solidrun/Makefile b/drivers/vdpa/solidrun/Makefile
new file mode 100644
index 000..c0aa3415bf7
--- /dev/null
+++ b/drivers/vdpa/solidrun/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_SNET_VDPA) += snet_vdpa.o
+snet_vdpa-$(CONFIG_SNET_VDPA) += snet_main.o
+ifdef CONFIG_HWMON
+snet_vdpa-$(CONFIG_SNET_VDPA) += snet_hwmon.o
+endif
diff --git a/drivers/vdpa/solidrun/snet_hwmon.c 
b/drivers/vdpa/solidrun/snet_hwmon.c
new file mode 100644
index 000..e695e36ff75
--- /dev/null
+++ b/drivers/vdpa/solidrun/snet_hwmon.c
@@ -0,0 +1,188 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * SolidRun DPU driver for control plane
+ *

[PATCH] vdpasim: fix memory leak when freeing IOTLBs

2022-12-13 Thread Jason Wang
After commit bda324fd037a ("vdpasim: control virtqueue support"),
vdpasim->iommu became an array of IOTLB, so we should clean the
mappings of each free one by one instead of just deleting the ranges
in the first IOTLB which may leak maps.

Fixes: bda324fd037a ("vdpasim: control virtqueue support")
Cc: Gautam Dawar 
Signed-off-by: Jason Wang 
---
 drivers/vdpa/vdpa_sim/vdpa_sim.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index b071f0d842fb..9668dc477843 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -690,7 +690,9 @@ static void vdpasim_free(struct vdpa_device *vdpa)
}
 
kvfree(vdpasim->buffer);
-   vhost_iotlb_free(vdpasim->iommu);
+   for (i = 0; i < vdpasim->dev_attr.nas; i++)
+   vhost_iotlb_reset(>iommu[i]);
+   kfree(vdpasim->iommu);
kfree(vdpasim->vqs);
kfree(vdpasim->config);
 }
-- 
2.25.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization