summaryrefslogtreecommitdiff
path: root/drivers/vdpa
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2020-12-08 05:36:21 +0300
committerJakub Kicinski <kuba@kernel.org>2020-12-08 05:36:21 +0300
commit8e98387b16b88440b06e57965f6b2d789acd9451 (patch)
tree6fbb49efda10ea2b4171a1f2ddee93a3d474bc1d /drivers/vdpa
parent374a96b9600ccf60083c0fec8f727e04752a7f0c (diff)
parent04b222f9577396a8d19bf2937d2a218dc2a3c7ac (diff)
downloadlinux-8e98387b16b88440b06e57965f6b2d789acd9451.tar.xz
Merge branch 'mlx5-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux
Saeed Mahameed says: ==================== mlx5-next auxbus support This pull request is targeting net-next and rdma-next branches. This series provides mlx5 support for auxiliary bus devices. It starts with a merge commit of tag 'auxbus-5.11-rc1' from gregkh/driver-core into mlx5-next, then the mlx5 patches that will convert mlx5 ulp devices (netdev, rdma, vdpa) to use the proper auxbus infrastructure instead of the internal mlx5 device and interface management implementation, which Leon is deleting at the end of this patchset. Link: https://lore.kernel.org/alsa-devel/20201026111849.1035786-1-leon@kernel.org/ Thanks to everyone for the joint effort ! * 'mlx5-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux: RDMA/mlx5: Remove IB representors dead code net/mlx5: Simplify eswitch mode check net/mlx5: Delete custom device management logic RDMA/mlx5: Convert mlx5_ib to use auxiliary bus net/mlx5e: Connect ethernet part to auxiliary bus vdpa/mlx5: Connect mlx5_vdpa to auxiliary bus net/mlx5: Register mlx5 devices to auxiliary virtual bus vdpa/mlx5: Make hardware definitions visible to all mlx5 devices net/mlx5_core: Clean driver version and name net/mlx5: Properly convey driver version to firmware driver core: auxiliary bus: minor coding style tweaks driver core: auxiliary bus: make remove function return void driver core: auxiliary bus: move slab.h from include file Add auxiliary bus support ==================== Link: https://lore.kernel.org/r/20201207053349.402772-1-saeed@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/vdpa')
-rw-r--r--drivers/vdpa/mlx5/Makefile2
-rw-r--r--drivers/vdpa/mlx5/core/mlx5_vdpa_ifc.h168
-rw-r--r--drivers/vdpa/mlx5/net/main.c76
-rw-r--r--drivers/vdpa/mlx5/net/mlx5_vnet.c53
-rw-r--r--drivers/vdpa/mlx5/net/mlx5_vnet.h24
5 files changed, 46 insertions, 277 deletions
diff --git a/drivers/vdpa/mlx5/Makefile b/drivers/vdpa/mlx5/Makefile
index 89a5bededc9f..f717978c83bf 100644
--- a/drivers/vdpa/mlx5/Makefile
+++ b/drivers/vdpa/mlx5/Makefile
@@ -1,4 +1,4 @@
subdir-ccflags-y += -I$(srctree)/drivers/vdpa/mlx5/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
+mlx5_vdpa-$(CONFIG_MLX5_VDPA_NET) += net/mlx5_vnet.o core/resources.o core/mr.o
diff --git a/drivers/vdpa/mlx5/core/mlx5_vdpa_ifc.h b/drivers/vdpa/mlx5/core/mlx5_vdpa_ifc.h
deleted file mode 100644
index f6f57a29b38e..000000000000
--- a/drivers/vdpa/mlx5/core/mlx5_vdpa_ifc.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
-/* Copyright (c) 2020 Mellanox Technologies Ltd. */
-
-#ifndef __MLX5_VDPA_IFC_H_
-#define __MLX5_VDPA_IFC_H_
-
-#include <linux/mlx5/mlx5_ifc.h>
-
-enum {
- MLX5_VIRTIO_Q_EVENT_MODE_NO_MSIX_MODE = 0x0,
- MLX5_VIRTIO_Q_EVENT_MODE_QP_MODE = 0x1,
- MLX5_VIRTIO_Q_EVENT_MODE_MSIX_MODE = 0x2,
-};
-
-enum {
- MLX5_VIRTIO_EMULATION_CAP_VIRTIO_QUEUE_TYPE_SPLIT = 0x1, // do I check this caps?
- MLX5_VIRTIO_EMULATION_CAP_VIRTIO_QUEUE_TYPE_PACKED = 0x2,
-};
-
-enum {
- MLX5_VIRTIO_EMULATION_VIRTIO_QUEUE_TYPE_SPLIT = 0,
- MLX5_VIRTIO_EMULATION_VIRTIO_QUEUE_TYPE_PACKED = 1,
-};
-
-struct mlx5_ifc_virtio_q_bits {
- u8 virtio_q_type[0x8];
- u8 reserved_at_8[0x5];
- u8 event_mode[0x3];
- u8 queue_index[0x10];
-
- u8 full_emulation[0x1];
- u8 virtio_version_1_0[0x1];
- u8 reserved_at_22[0x2];
- u8 offload_type[0x4];
- u8 event_qpn_or_msix[0x18];
-
- u8 doorbell_stride_index[0x10];
- u8 queue_size[0x10];
-
- u8 device_emulation_id[0x20];
-
- u8 desc_addr[0x40];
-
- u8 used_addr[0x40];
-
- u8 available_addr[0x40];
-
- u8 virtio_q_mkey[0x20];
-
- u8 max_tunnel_desc[0x10];
- u8 reserved_at_170[0x8];
- u8 error_type[0x8];
-
- u8 umem_1_id[0x20];
-
- u8 umem_1_size[0x20];
-
- u8 umem_1_offset[0x40];
-
- u8 umem_2_id[0x20];
-
- u8 umem_2_size[0x20];
-
- u8 umem_2_offset[0x40];
-
- u8 umem_3_id[0x20];
-
- u8 umem_3_size[0x20];
-
- u8 umem_3_offset[0x40];
-
- u8 counter_set_id[0x20];
-
- u8 reserved_at_320[0x8];
- u8 pd[0x18];
-
- u8 reserved_at_340[0xc0];
-};
-
-struct mlx5_ifc_virtio_net_q_object_bits {
- u8 modify_field_select[0x40];
-
- u8 reserved_at_40[0x20];
-
- u8 vhca_id[0x10];
- u8 reserved_at_70[0x10];
-
- u8 queue_feature_bit_mask_12_3[0xa];
- u8 dirty_bitmap_dump_enable[0x1];
- u8 vhost_log_page[0x5];
- u8 reserved_at_90[0xc];
- u8 state[0x4];
-
- u8 reserved_at_a0[0x5];
- u8 queue_feature_bit_mask_2_0[0x3];
- u8 tisn_or_qpn[0x18];
-
- u8 dirty_bitmap_mkey[0x20];
-
- u8 dirty_bitmap_size[0x20];
-
- u8 dirty_bitmap_addr[0x40];
-
- u8 hw_available_index[0x10];
- u8 hw_used_index[0x10];
-
- u8 reserved_at_160[0xa0];
-
- struct mlx5_ifc_virtio_q_bits virtio_q_context;
-};
-
-struct mlx5_ifc_create_virtio_net_q_in_bits {
- struct mlx5_ifc_general_obj_in_cmd_hdr_bits general_obj_in_cmd_hdr;
-
- struct mlx5_ifc_virtio_net_q_object_bits obj_context;
-};
-
-struct mlx5_ifc_create_virtio_net_q_out_bits {
- struct mlx5_ifc_general_obj_out_cmd_hdr_bits general_obj_out_cmd_hdr;
-};
-
-struct mlx5_ifc_destroy_virtio_net_q_in_bits {
- struct mlx5_ifc_general_obj_in_cmd_hdr_bits general_obj_out_cmd_hdr;
-};
-
-struct mlx5_ifc_destroy_virtio_net_q_out_bits {
- struct mlx5_ifc_general_obj_out_cmd_hdr_bits general_obj_out_cmd_hdr;
-};
-
-struct mlx5_ifc_query_virtio_net_q_in_bits {
- struct mlx5_ifc_general_obj_in_cmd_hdr_bits general_obj_in_cmd_hdr;
-};
-
-struct mlx5_ifc_query_virtio_net_q_out_bits {
- struct mlx5_ifc_general_obj_out_cmd_hdr_bits general_obj_out_cmd_hdr;
-
- struct mlx5_ifc_virtio_net_q_object_bits obj_context;
-};
-
-enum {
- MLX5_VIRTQ_MODIFY_MASK_STATE = (u64)1 << 0,
- MLX5_VIRTQ_MODIFY_MASK_DIRTY_BITMAP_PARAMS = (u64)1 << 3,
- MLX5_VIRTQ_MODIFY_MASK_DIRTY_BITMAP_DUMP_ENABLE = (u64)1 << 4,
-};
-
-enum {
- MLX5_VIRTIO_NET_Q_OBJECT_STATE_INIT = 0x0,
- MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY = 0x1,
- MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND = 0x2,
- MLX5_VIRTIO_NET_Q_OBJECT_STATE_ERR = 0x3,
-};
-
-enum {
- MLX5_RQTC_LIST_Q_TYPE_RQ = 0x0,
- MLX5_RQTC_LIST_Q_TYPE_VIRTIO_NET_Q = 0x1,
-};
-
-struct mlx5_ifc_modify_virtio_net_q_in_bits {
- struct mlx5_ifc_general_obj_in_cmd_hdr_bits general_obj_in_cmd_hdr;
-
- struct mlx5_ifc_virtio_net_q_object_bits obj_context;
-};
-
-struct mlx5_ifc_modify_virtio_net_q_out_bits {
- struct mlx5_ifc_general_obj_out_cmd_hdr_bits general_obj_out_cmd_hdr;
-};
-
-#endif /* __MLX5_VDPA_IFC_H_ */
diff --git a/drivers/vdpa/mlx5/net/main.c b/drivers/vdpa/mlx5/net/main.c
deleted file mode 100644
index 838cd98386ff..000000000000
--- a/drivers/vdpa/mlx5/net/main.c
+++ /dev/null
@@ -1,76 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
-/* Copyright (c) 2020 Mellanox Technologies Ltd. */
-
-#include <linux/module.h>
-#include <linux/mlx5/driver.h>
-#include <linux/mlx5/device.h>
-#include "mlx5_vdpa_ifc.h"
-#include "mlx5_vnet.h"
-
-MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>");
-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 mlx5_register_interface(&mlx5_vdpa_interface);
-}
-
-static void __exit mlx5_vdpa_exit(void)
-{
- mlx5_unregister_interface(&mlx5_vdpa_interface);
-}
-
-module_init(mlx5_vdpa_init);
-module_exit(mlx5_vdpa_exit);
diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index 1fa6fcac8299..f1d54814db97 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -1,18 +1,28 @@
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
/* Copyright (c) 2020 Mellanox Technologies Ltd. */
+#include <linux/module.h>
#include <linux/vdpa.h>
+#include <linux/vringh.h>
+#include <uapi/linux/virtio_net.h>
#include <uapi/linux/virtio_ids.h>
#include <linux/virtio_config.h>
+#include <linux/auxiliary_bus.h>
+#include <linux/mlx5/cq.h>
#include <linux/mlx5/qp.h>
#include <linux/mlx5/device.h>
+#include <linux/mlx5/driver.h>
#include <linux/mlx5/vport.h>
#include <linux/mlx5/fs.h>
-#include <linux/mlx5/device.h>
-#include "mlx5_vnet.h"
-#include "mlx5_vdpa_ifc.h"
+#include <linux/mlx5/mlx5_ifc_vdpa.h>
#include "mlx5_vdpa.h"
+MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>");
+MODULE_DESCRIPTION("Mellanox VDPA driver");
+MODULE_LICENSE("Dual BSD/GPL");
+
+#define to_mlx5_vdpa_ndev(__mvdev) \
+ container_of(__mvdev, struct mlx5_vdpa_net, mvdev)
#define to_mvdev(__vdev) container_of((__vdev), struct mlx5_vdpa_dev, vdev)
#define VALID_FEATURES_MASK \
@@ -159,6 +169,11 @@ static bool mlx5_vdpa_debug;
mlx5_vdpa_info(mvdev, "%s\n", #_status); \
} while (0)
+static inline u32 mlx5_vdpa_max_qps(int max_vqs)
+{
+ return max_vqs / 2;
+}
+
static void print_status(struct mlx5_vdpa_dev *mvdev, u8 status, bool set)
{
if (status & ~VALID_STATUS_MASK)
@@ -1928,8 +1943,11 @@ static void init_mvqs(struct mlx5_vdpa_net *ndev)
}
}
-void *mlx5_vdpa_add_dev(struct mlx5_core_dev *mdev)
+static int mlx5v_probe(struct auxiliary_device *adev,
+ const struct auxiliary_device_id *id)
{
+ struct mlx5_adev *madev = container_of(adev, struct mlx5_adev, adev);
+ struct mlx5_core_dev *mdev = madev->mdev;
struct virtio_net_config *config;
struct mlx5_vdpa_dev *mvdev;
struct mlx5_vdpa_net *ndev;
@@ -1943,7 +1961,7 @@ void *mlx5_vdpa_add_dev(struct mlx5_core_dev *mdev)
ndev = vdpa_alloc_device(struct mlx5_vdpa_net, mvdev.vdev, mdev->device, &mlx5_vdpa_ops,
2 * mlx5_vdpa_max_qps(max_vqs));
if (IS_ERR(ndev))
- return ndev;
+ return PTR_ERR(ndev);
ndev->mvdev.max_vqs = max_vqs;
mvdev = &ndev->mvdev;
@@ -1972,7 +1990,8 @@ void *mlx5_vdpa_add_dev(struct mlx5_core_dev *mdev)
if (err)
goto err_reg;
- return ndev;
+ dev_set_drvdata(&adev->dev, ndev);
+ return 0;
err_reg:
free_resources(ndev);
@@ -1981,10 +2000,28 @@ err_res:
err_mtu:
mutex_destroy(&ndev->reslock);
put_device(&mvdev->vdev.dev);
- return ERR_PTR(err);
+ return err;
}
-void mlx5_vdpa_remove_dev(struct mlx5_vdpa_dev *mvdev)
+static void mlx5v_remove(struct auxiliary_device *adev)
{
+ struct mlx5_vdpa_dev *mvdev = dev_get_drvdata(&adev->dev);
+
vdpa_unregister_device(&mvdev->vdev);
}
+
+static const struct auxiliary_device_id mlx5v_id_table[] = {
+ { .name = MLX5_ADEV_NAME ".vnet", },
+ {},
+};
+
+MODULE_DEVICE_TABLE(auxiliary, mlx5v_id_table);
+
+static struct auxiliary_driver mlx5v_driver = {
+ .name = "vnet",
+ .probe = mlx5v_probe,
+ .remove = mlx5v_remove,
+ .id_table = mlx5v_id_table,
+};
+
+module_auxiliary_driver(mlx5v_driver);
diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.h b/drivers/vdpa/mlx5/net/mlx5_vnet.h
deleted file mode 100644
index f2d6d68b020e..000000000000
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
-/* Copyright (c) 2020 Mellanox Technologies Ltd. */
-
-#ifndef __MLX5_VNET_H_
-#define __MLX5_VNET_H_
-
-#include <linux/vdpa.h>
-#include <linux/virtio_net.h>
-#include <linux/vringh.h>
-#include <linux/mlx5/driver.h>
-#include <linux/mlx5/cq.h>
-#include <linux/mlx5/qp.h>
-#include "mlx5_vdpa.h"
-
-static inline u32 mlx5_vdpa_max_qps(int max_vqs)
-{
- return max_vqs / 2;
-}
-
-#define to_mlx5_vdpa_ndev(__mvdev) container_of(__mvdev, struct mlx5_vdpa_net, mvdev)
-void *mlx5_vdpa_add_dev(struct mlx5_core_dev *mdev);
-void mlx5_vdpa_remove_dev(struct mlx5_vdpa_dev *mvdev);
-
-#endif /* __MLX5_VNET_H_ */