Re: [PATCH V2 vhost next 10/10] vdpa/mlx5: Add VDPA driver for supported mlx5 devices

2020-07-22 Thread Eli Cohen
On Mon, Jul 20, 2020 at 08:55:54PM +0800, kernel test robot wrote:
> Hi Eli,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on next-20200717]
> 
> url:
> https://github.com/0day-ci/linux/commits/Eli-Cohen/VDPA-support-for-Mellanox-ConnectX-devices/20200720-160220
> base:aab7ee9f8ff0110bfcd594b33dc33748dc1baf46
> config: arc-allyesconfig (attached as .config)
> compiler: arc-elf-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
> wget 
> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross 
> ARCH=arc 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot 
> 
> All errors (new ones prefixed by >>):
> 
> >> drivers/vdpa/mlx5/net/main.c:7:10: fatal error: mlx5_vdpa_ifc.h: No such 
> >> file or directory
>7 | #include "mlx5_vdpa_ifc.h"
>  |  ^

Does anyone understand this error? The code compiles with no issues. I
think there may be an issue with the tool not interpreting the include
path in the makefile:

subdir-ccflags-y += -I$(src)/core

>compilation terminated.
> --
>In file included from drivers/vdpa/mlx5/net/mlx5_vnet.c:12:
> >> drivers/vdpa/mlx5/net/mlx5_vnet.h:13:10: fatal error: mlx5_vdpa.h: No such 
> >> file or directory
>   13 | #include "mlx5_vdpa.h"
>  |  ^
>compilation terminated.
> 
> vim +7 drivers/vdpa/mlx5/net/main.c
> 
>  3
>  4#include 
>  5#include 
>  6#include 
>> 7#include "mlx5_vdpa_ifc.h"
>  8#include "mlx5_vnet.h"
>  9
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org




Re: [PATCH V2 vhost next 10/10] vdpa/mlx5: Add VDPA driver for supported mlx5 devices

2020-07-20 Thread Jason Wang



On 2020/7/20 下午3:14, Eli Cohen wrote:

Add a front end VDPA driver that registers in the VDPA bus and provides
networking to a guest. The VDPA driver creates the necessary resources
on the VF it is driving such that data path will be offloaded.

Notifications are being communicated through the driver.

Currently, only VFs are supported. In subsequent patches we will have
devlink support to control which VF is used for VDPA and which function
is used for regular networking.

Reviewed-by: Parav Pandit
Signed-off-by: Eli Cohen
---
Changes from V0:
1. Fix include path usage
2. Fix use after free in qp_create()
3. Consistently use mvq->initialized to check if a vq was initialized.
4. Remove unused local variable.
5. Defer modifyig vq to ready to driver ok
6. suspend hardware vq in set_vq_ready(0)
7. Remove reservation for control VQ since it multi queue is not supported in 
this version
8. Avoid call put_device() since this is not a pci device driver.



Looks good to me.

Acked-by: Jason Wang 




Re: [PATCH V2 vhost next 10/10] vdpa/mlx5: Add VDPA driver for supported mlx5 devices

2020-07-20 Thread kernel test robot
Hi Eli,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20200717]

url:
https://github.com/0day-ci/linux/commits/Eli-Cohen/VDPA-support-for-Mellanox-ConnectX-devices/20200720-160220
base:aab7ee9f8ff0110bfcd594b33dc33748dc1baf46
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 
cf1105069648446d58adfb7a6cc590013d6886ba)
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   In file included from drivers/vdpa/mlx5/net/mlx5_vnet.c:12:
>> drivers/vdpa/mlx5/net/mlx5_vnet.h:13:10: fatal error: 'mlx5_vdpa.h' file not 
>> found
   #include "mlx5_vdpa.h"
^
   1 error generated.

vim +13 drivers/vdpa/mlx5/net/mlx5_vnet.h

 6  
 7  #include 
 8  #include 
 9  #include 
10  #include 
11  #include 
12  #include 
  > 13  #include "mlx5_vdpa.h"
14  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


Re: [PATCH V2 vhost next 10/10] vdpa/mlx5: Add VDPA driver for supported mlx5 devices

2020-07-20 Thread kernel test robot
Hi Eli,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20200717]

url:
https://github.com/0day-ci/linux/commits/Eli-Cohen/VDPA-support-for-Mellanox-ConnectX-devices/20200720-160220
base:aab7ee9f8ff0110bfcd594b33dc33748dc1baf46
config: arc-allyesconfig (attached as .config)
compiler: arc-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

>> drivers/vdpa/mlx5/net/main.c:7:10: fatal error: mlx5_vdpa_ifc.h: No such 
>> file or directory
   7 | #include "mlx5_vdpa_ifc.h"
 |  ^
   compilation terminated.
--
   In file included from drivers/vdpa/mlx5/net/mlx5_vnet.c:12:
>> drivers/vdpa/mlx5/net/mlx5_vnet.h:13:10: fatal error: mlx5_vdpa.h: No such 
>> file or directory
  13 | #include "mlx5_vdpa.h"
 |  ^
   compilation terminated.

vim +7 drivers/vdpa/mlx5/net/main.c

 3  
 4  #include 
 5  #include 
 6  #include 
   > 7  #include "mlx5_vdpa_ifc.h"
 8  #include "mlx5_vnet.h"
 9  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


[PATCH V2 vhost next 10/10] vdpa/mlx5: Add VDPA driver for supported mlx5 devices

2020-07-20 Thread Eli Cohen
Add a front end VDPA driver that registers in the VDPA bus and provides
networking to a guest. The VDPA driver creates the necessary resources
on the VF it is driving such that data path will be offloaded.

Notifications are being communicated through the driver.

Currently, only VFs are supported. In subsequent patches we will have
devlink support to control which VF is used for VDPA and which function
is used for regular networking.

Reviewed-by: Parav Pandit 
Signed-off-by: Eli Cohen 
---
Changes from V0:
1. Fix include path usage
2. Fix use after free in qp_create()
3. Consistently use mvq->initialized to check if a vq was initialized.
4. Remove unused local variable.
5. Defer modifyig vq to ready to driver ok
6. suspend hardware vq in set_vq_ready(0)
7. Remove reservation for control VQ since it multi queue is not supported in 
this version
8. Avoid call put_device() since this is not a pci device driver.

 drivers/vdpa/Kconfig  |   10 +
 drivers/vdpa/mlx5/Makefile|5 +-
 drivers/vdpa/mlx5/core/mr.c   |2 +-
 drivers/vdpa/mlx5/net/main.c  |   76 ++
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 1950 +
 drivers/vdpa/mlx5/net/mlx5_vnet.h |   24 +
 6 files changed, 2065 insertions(+), 2 deletions(-)
 create mode 100644 drivers/vdpa/mlx5/net/main.c
 create mode 100644 drivers/vdpa/mlx5/net/mlx5_vnet.c
 create mode 100644 drivers/vdpa/mlx5/net/mlx5_vnet.h

diff --git a/drivers/vdpa/Kconfig b/drivers/vdpa/Kconfig
index 48a1a776dd86..809cb4c2eecf 100644
--- a/drivers/vdpa/Kconfig
+++ b/drivers/vdpa/Kconfig
@@ -36,4 +36,14 @@ config MLX5_VDPA
  Support library for Mellanox VDPA drivers. Provides code that is
  common for all types of VDPA drivers.
 
+config MLX5_VDPA_NET
+   tristate "vDPA driver for ConnectX devices"
+   depends on MLX5_VDPA
+   default n
+   help
+ VDPA network driver for ConnectX6 and newer. Provides offloading
+ of virtio net datapath such that descriptors put on the ring will
+ be executed by the hardware. It also supports a variety of stateless
+ offloads depending on the actual device used and firmware version.
+
 endif # VDPA
diff --git a/drivers/vdpa/mlx5/Makefile b/drivers/vdpa/mlx5/Makefile
index b347c62032ea..3f8850c1a300 100644
--- a/drivers/vdpa/mlx5/Makefile
+++ b/drivers/vdpa/mlx5/Makefile
@@ -1 +1,4 @@
-obj-$(CONFIG_MLX5_VDPA) += core/resources.o core/mr.o
+subdir-ccflags-y += -I$(src)/core
+
+obj-$(CONFIG_MLX5_VDPA_NET) += mlx5_vdpa.o
+mlx5_vdpa-$(CONFIG_MLX5_VDPA_NET) += net/main.o net/mlx5_vnet.o 
core/resources.o core/mr.o
diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c
index 975aa45fd78b..34e3bbb80df8 100644
--- a/drivers/vdpa/mlx5/core/mr.c
+++ b/drivers/vdpa/mlx5/core/mr.c
@@ -453,7 +453,7 @@ int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, 
struct vhost_iotlb *io
 bool *change_map)
 {
struct mlx5_vdpa_mr *mr = >mr;
-   int err;
+   int err = 0;
 
*change_map = false;
if (map_empty(iotlb)) {
diff --git a/drivers/vdpa/mlx5/net/main.c b/drivers/vdpa/mlx5/net/main.c
new file mode 100644
index ..838cd98386ff
--- /dev/null
+++ b/drivers/vdpa/mlx5/net/main.c
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
+/* Copyright (c) 2020 Mellanox Technologies Ltd. */
+
+#include 
+#include 
+#include 
+#include "mlx5_vdpa_ifc.h"
+#include "mlx5_vnet.h"
+
+MODULE_AUTHOR("Eli Cohen ");
+MODULE_DESCRIPTION("Mellanox VDPA driver");
+MODULE_LICENSE("Dual BSD/GPL");
+
+static bool required_caps_supported(struct mlx5_core_dev *mdev)
+{
+   u8 event_mode;
+   u64 got;
+
+   got = MLX5_CAP_GEN_64(mdev, general_obj_types);
+
+   if (!(got & MLX5_GENERAL_OBJ_TYPES_CAP_VIRTIO_NET_Q))
+   return false;
+
+   event_mode = MLX5_CAP_DEV_VDPA_EMULATION(mdev, event_mode);
+   if (!(event_mode & MLX5_VIRTIO_Q_EVENT_MODE_QP_MODE))
+   return false;
+
+   if (!MLX5_CAP_DEV_VDPA_EMULATION(mdev, eth_frame_offload_type))
+   return false;
+
+   return true;
+}
+
+static void *mlx5_vdpa_add(struct mlx5_core_dev *mdev)
+{
+   struct mlx5_vdpa_dev *vdev;
+
+   if (mlx5_core_is_pf(mdev))
+   return NULL;
+
+   if (!required_caps_supported(mdev)) {
+   dev_info(mdev->device, "virtio net emulation not supported\n");
+   return NULL;
+   }
+   vdev = mlx5_vdpa_add_dev(mdev);
+   if (IS_ERR(vdev))
+   return NULL;
+
+   return vdev;
+}
+
+static void mlx5_vdpa_remove(struct mlx5_core_dev *mdev, void *context)
+{
+   struct mlx5_vdpa_dev *vdev = context;
+
+   mlx5_vdpa_remove_dev(vdev);
+}
+
+static struct mlx5_interface mlx5_vdpa_interface = {
+   .add = mlx5_vdpa_add,
+   .remove = mlx5_vdpa_remove,
+   .protocol = MLX5_INTERFACE_PROTOCOL_VDPA,
+};
+
+static int __init mlx5_vdpa_init(void)
+{
+   return 

[PATCH V2 vhost next 10/10] vdpa/mlx5: Add VDPA driver for supported mlx5 devices

2020-07-20 Thread Eli Cohen
Add a front end VDPA driver that registers in the VDPA bus and provides
networking to a guest. The VDPA driver creates the necessary resources
on the VF it is driving such that data path will be offloaded.

Notifications are being communicated through the driver.

Currently, only VFs are supported. In subsequent patches we will have
devlink support to control which VF is used for VDPA and which function
is used for regular networking.

Reviewed-by: Parav Pandit 
Signed-off-by: Eli Cohen 
---
Changes from V0:
1. Fix include path usage
2. Fix use after free in qp_create()
3. Consistently use mvq->initialized to check if a vq was initialized.
4. Remove unused local variable.
5. Defer modifyig vq to ready to driver ok
6. suspend hardware vq in set_vq_ready(0)
7. Remove reservation for control VQ since it multi queue is not supported in 
this version
8. Avoid call put_device() since this is not a pci device driver.

 drivers/vdpa/Kconfig  |   10 +
 drivers/vdpa/mlx5/Makefile|5 +-
 drivers/vdpa/mlx5/core/mr.c   |2 +-
 drivers/vdpa/mlx5/net/main.c  |   76 ++
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 1950 +
 drivers/vdpa/mlx5/net/mlx5_vnet.h |   24 +
 6 files changed, 2065 insertions(+), 2 deletions(-)
 create mode 100644 drivers/vdpa/mlx5/net/main.c
 create mode 100644 drivers/vdpa/mlx5/net/mlx5_vnet.c
 create mode 100644 drivers/vdpa/mlx5/net/mlx5_vnet.h

diff --git a/drivers/vdpa/Kconfig b/drivers/vdpa/Kconfig
index 48a1a776dd86..809cb4c2eecf 100644
--- a/drivers/vdpa/Kconfig
+++ b/drivers/vdpa/Kconfig
@@ -36,4 +36,14 @@ config MLX5_VDPA
  Support library for Mellanox VDPA drivers. Provides code that is
  common for all types of VDPA drivers.
 
+config MLX5_VDPA_NET
+   tristate "vDPA driver for ConnectX devices"
+   depends on MLX5_VDPA
+   default n
+   help
+ VDPA network driver for ConnectX6 and newer. Provides offloading
+ of virtio net datapath such that descriptors put on the ring will
+ be executed by the hardware. It also supports a variety of stateless
+ offloads depending on the actual device used and firmware version.
+
 endif # VDPA
diff --git a/drivers/vdpa/mlx5/Makefile b/drivers/vdpa/mlx5/Makefile
index b347c62032ea..3f8850c1a300 100644
--- a/drivers/vdpa/mlx5/Makefile
+++ b/drivers/vdpa/mlx5/Makefile
@@ -1 +1,4 @@
-obj-$(CONFIG_MLX5_VDPA) += core/resources.o core/mr.o
+subdir-ccflags-y += -I$(src)/core
+
+obj-$(CONFIG_MLX5_VDPA_NET) += mlx5_vdpa.o
+mlx5_vdpa-$(CONFIG_MLX5_VDPA_NET) += net/main.o net/mlx5_vnet.o 
core/resources.o core/mr.o
diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c
index 975aa45fd78b..34e3bbb80df8 100644
--- a/drivers/vdpa/mlx5/core/mr.c
+++ b/drivers/vdpa/mlx5/core/mr.c
@@ -453,7 +453,7 @@ int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, 
struct vhost_iotlb *io
 bool *change_map)
 {
struct mlx5_vdpa_mr *mr = >mr;
-   int err;
+   int err = 0;
 
*change_map = false;
if (map_empty(iotlb)) {
diff --git a/drivers/vdpa/mlx5/net/main.c b/drivers/vdpa/mlx5/net/main.c
new file mode 100644
index ..838cd98386ff
--- /dev/null
+++ b/drivers/vdpa/mlx5/net/main.c
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
+/* Copyright (c) 2020 Mellanox Technologies Ltd. */
+
+#include 
+#include 
+#include 
+#include "mlx5_vdpa_ifc.h"
+#include "mlx5_vnet.h"
+
+MODULE_AUTHOR("Eli Cohen ");
+MODULE_DESCRIPTION("Mellanox VDPA driver");
+MODULE_LICENSE("Dual BSD/GPL");
+
+static bool required_caps_supported(struct mlx5_core_dev *mdev)
+{
+   u8 event_mode;
+   u64 got;
+
+   got = MLX5_CAP_GEN_64(mdev, general_obj_types);
+
+   if (!(got & MLX5_GENERAL_OBJ_TYPES_CAP_VIRTIO_NET_Q))
+   return false;
+
+   event_mode = MLX5_CAP_DEV_VDPA_EMULATION(mdev, event_mode);
+   if (!(event_mode & MLX5_VIRTIO_Q_EVENT_MODE_QP_MODE))
+   return false;
+
+   if (!MLX5_CAP_DEV_VDPA_EMULATION(mdev, eth_frame_offload_type))
+   return false;
+
+   return true;
+}
+
+static void *mlx5_vdpa_add(struct mlx5_core_dev *mdev)
+{
+   struct mlx5_vdpa_dev *vdev;
+
+   if (mlx5_core_is_pf(mdev))
+   return NULL;
+
+   if (!required_caps_supported(mdev)) {
+   dev_info(mdev->device, "virtio net emulation not supported\n");
+   return NULL;
+   }
+   vdev = mlx5_vdpa_add_dev(mdev);
+   if (IS_ERR(vdev))
+   return NULL;
+
+   return vdev;
+}
+
+static void mlx5_vdpa_remove(struct mlx5_core_dev *mdev, void *context)
+{
+   struct mlx5_vdpa_dev *vdev = context;
+
+   mlx5_vdpa_remove_dev(vdev);
+}
+
+static struct mlx5_interface mlx5_vdpa_interface = {
+   .add = mlx5_vdpa_add,
+   .remove = mlx5_vdpa_remove,
+   .protocol = MLX5_INTERFACE_PROTOCOL_VDPA,
+};
+
+static int __init mlx5_vdpa_init(void)
+{
+   return