mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio updates from Michael Tsirkin: - vdpa generic device type support - more virtio hardening for broken devices (but on the same theme, revert some virtio hotplug hardening patches - they were misusing some interrupt flags and had to be reverted) - RSS support in virtio-net - max device MTU support in mlx5 vdpa - akcipher support in virtio-crypto - shared IRQ support in ifcvf vdpa - a minor performance improvement in vhost - enable virtio mem for ARM64 - beginnings of advance dma support - cleanups, fixes all over the place * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: (33 commits) vdpa/mlx5: Avoid processing works if workqueue was destroyed vhost: handle error while adding split ranges to iotlb vdpa: support exposing the count of vqs to userspace vdpa: change the type of nvqs to u32 vdpa: support exposing the config size to userspace vdpa/mlx5: re-create forwarding rules after mac modified virtio: pci: check bar values read from virtio config space Revert "virtio_pci: harden MSI-X interrupts" Revert "virtio-pci: harden INTX interrupts" drivers/net/virtio_net: Added RSS hash report control. drivers/net/virtio_net: Added RSS hash report. drivers/net/virtio_net: Added basic RSS support. drivers/net/virtio_net: Fixed padded vheader to use v1 with hash. virtio: use virtio_device_ready() in virtio_device_restore() tools/virtio: compile with -pthread tools/virtio: fix after premapped buf support virtio_ring: remove flags check for unmap packed indirect desc virtio_ring: remove flags check for unmap split indirect desc virtio_ring: rename vring_unmap_state_packed() to vring_unmap_extra_packed() net/mlx5: Add support for configuring max device MTU ...
This commit is contained in:
@@ -3,8 +3,11 @@ config CRYPTO_DEV_VIRTIO
|
||||
tristate "VirtIO crypto driver"
|
||||
depends on VIRTIO
|
||||
select CRYPTO_AEAD
|
||||
select CRYPTO_AKCIPHER2
|
||||
select CRYPTO_SKCIPHER
|
||||
select CRYPTO_ENGINE
|
||||
select CRYPTO_RSA
|
||||
select MPILIB
|
||||
help
|
||||
This driver provides support for virtio crypto device. If you
|
||||
choose 'M' here, this module will be called virtio_crypto.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
obj-$(CONFIG_CRYPTO_DEV_VIRTIO) += virtio_crypto.o
|
||||
virtio_crypto-objs := \
|
||||
virtio_crypto_algs.o \
|
||||
virtio_crypto_skcipher_algs.o \
|
||||
virtio_crypto_akcipher_algs.o \
|
||||
virtio_crypto_mgr.o \
|
||||
virtio_crypto_core.o
|
||||
|
||||
585
drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
Normal file
585
drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -56,6 +56,7 @@ struct virtio_crypto {
|
||||
u32 mac_algo_l;
|
||||
u32 mac_algo_h;
|
||||
u32 aead_algo;
|
||||
u32 akcipher_algo;
|
||||
|
||||
/* Maximum length of cipher key */
|
||||
u32 max_cipher_key_len;
|
||||
@@ -129,7 +130,9 @@ static inline int virtio_crypto_get_current_node(void)
|
||||
return node;
|
||||
}
|
||||
|
||||
int virtio_crypto_algs_register(struct virtio_crypto *vcrypto);
|
||||
void virtio_crypto_algs_unregister(struct virtio_crypto *vcrypto);
|
||||
int virtio_crypto_skcipher_algs_register(struct virtio_crypto *vcrypto);
|
||||
void virtio_crypto_skcipher_algs_unregister(struct virtio_crypto *vcrypto);
|
||||
int virtio_crypto_akcipher_algs_register(struct virtio_crypto *vcrypto);
|
||||
void virtio_crypto_akcipher_algs_unregister(struct virtio_crypto *vcrypto);
|
||||
|
||||
#endif /* _VIRTIO_CRYPTO_COMMON_H */
|
||||
|
||||
@@ -297,6 +297,7 @@ static int virtcrypto_probe(struct virtio_device *vdev)
|
||||
u32 mac_algo_l = 0;
|
||||
u32 mac_algo_h = 0;
|
||||
u32 aead_algo = 0;
|
||||
u32 akcipher_algo = 0;
|
||||
u32 crypto_services = 0;
|
||||
|
||||
if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1))
|
||||
@@ -348,6 +349,9 @@ static int virtcrypto_probe(struct virtio_device *vdev)
|
||||
mac_algo_h, &mac_algo_h);
|
||||
virtio_cread_le(vdev, struct virtio_crypto_config,
|
||||
aead_algo, &aead_algo);
|
||||
if (crypto_services & (1 << VIRTIO_CRYPTO_SERVICE_AKCIPHER))
|
||||
virtio_cread_le(vdev, struct virtio_crypto_config,
|
||||
akcipher_algo, &akcipher_algo);
|
||||
|
||||
/* Add virtio crypto device to global table */
|
||||
err = virtcrypto_devmgr_add_dev(vcrypto);
|
||||
@@ -374,7 +378,7 @@ static int virtcrypto_probe(struct virtio_device *vdev)
|
||||
vcrypto->mac_algo_h = mac_algo_h;
|
||||
vcrypto->hash_algo = hash_algo;
|
||||
vcrypto->aead_algo = aead_algo;
|
||||
|
||||
vcrypto->akcipher_algo = akcipher_algo;
|
||||
|
||||
dev_info(&vdev->dev,
|
||||
"max_queues: %u, max_cipher_key_len: %u, max_auth_key_len: %u, max_size 0x%llx\n",
|
||||
|
||||
@@ -237,8 +237,14 @@ struct virtio_crypto *virtcrypto_get_dev_node(int node, uint32_t service,
|
||||
*/
|
||||
int virtcrypto_dev_start(struct virtio_crypto *vcrypto)
|
||||
{
|
||||
if (virtio_crypto_algs_register(vcrypto)) {
|
||||
pr_err("virtio_crypto: Failed to register crypto algs\n");
|
||||
if (virtio_crypto_skcipher_algs_register(vcrypto)) {
|
||||
pr_err("virtio_crypto: Failed to register crypto skcipher algs\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (virtio_crypto_akcipher_algs_register(vcrypto)) {
|
||||
pr_err("virtio_crypto: Failed to register crypto akcipher algs\n");
|
||||
virtio_crypto_skcipher_algs_unregister(vcrypto);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
@@ -257,7 +263,8 @@ int virtcrypto_dev_start(struct virtio_crypto *vcrypto)
|
||||
*/
|
||||
void virtcrypto_dev_stop(struct virtio_crypto *vcrypto)
|
||||
{
|
||||
virtio_crypto_algs_unregister(vcrypto);
|
||||
virtio_crypto_skcipher_algs_unregister(vcrypto);
|
||||
virtio_crypto_akcipher_algs_unregister(vcrypto);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -312,6 +319,10 @@ bool virtcrypto_algo_is_supported(struct virtio_crypto *vcrypto,
|
||||
case VIRTIO_CRYPTO_SERVICE_AEAD:
|
||||
algo_mask = vcrypto->aead_algo;
|
||||
break;
|
||||
|
||||
case VIRTIO_CRYPTO_SERVICE_AKCIPHER:
|
||||
algo_mask = vcrypto->akcipher_algo;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(algo_mask & (1u << algo)))
|
||||
|
||||
@@ -613,7 +613,7 @@ static struct virtio_crypto_algo virtio_crypto_algs[] = { {
|
||||
},
|
||||
} };
|
||||
|
||||
int virtio_crypto_algs_register(struct virtio_crypto *vcrypto)
|
||||
int virtio_crypto_skcipher_algs_register(struct virtio_crypto *vcrypto)
|
||||
{
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
@@ -644,7 +644,7 @@ unlock:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void virtio_crypto_algs_unregister(struct virtio_crypto *vcrypto)
|
||||
void virtio_crypto_skcipher_algs_unregister(struct virtio_crypto *vcrypto)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,47 +10,31 @@
|
||||
|
||||
#include "ifcvf_base.h"
|
||||
|
||||
static inline u8 ifc_ioread8(u8 __iomem *addr)
|
||||
{
|
||||
return ioread8(addr);
|
||||
}
|
||||
static inline u16 ifc_ioread16 (__le16 __iomem *addr)
|
||||
{
|
||||
return ioread16(addr);
|
||||
}
|
||||
|
||||
static inline u32 ifc_ioread32(__le32 __iomem *addr)
|
||||
{
|
||||
return ioread32(addr);
|
||||
}
|
||||
|
||||
static inline void ifc_iowrite8(u8 value, u8 __iomem *addr)
|
||||
{
|
||||
iowrite8(value, addr);
|
||||
}
|
||||
|
||||
static inline void ifc_iowrite16(u16 value, __le16 __iomem *addr)
|
||||
{
|
||||
iowrite16(value, addr);
|
||||
}
|
||||
|
||||
static inline void ifc_iowrite32(u32 value, __le32 __iomem *addr)
|
||||
{
|
||||
iowrite32(value, addr);
|
||||
}
|
||||
|
||||
static void ifc_iowrite64_twopart(u64 val,
|
||||
__le32 __iomem *lo, __le32 __iomem *hi)
|
||||
{
|
||||
ifc_iowrite32((u32)val, lo);
|
||||
ifc_iowrite32(val >> 32, hi);
|
||||
}
|
||||
|
||||
struct ifcvf_adapter *vf_to_adapter(struct ifcvf_hw *hw)
|
||||
{
|
||||
return container_of(hw, struct ifcvf_adapter, vf);
|
||||
}
|
||||
|
||||
u16 ifcvf_set_vq_vector(struct ifcvf_hw *hw, u16 qid, int vector)
|
||||
{
|
||||
struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg;
|
||||
|
||||
vp_iowrite16(qid, &cfg->queue_select);
|
||||
vp_iowrite16(vector, &cfg->queue_msix_vector);
|
||||
|
||||
return vp_ioread16(&cfg->queue_msix_vector);
|
||||
}
|
||||
|
||||
u16 ifcvf_set_config_vector(struct ifcvf_hw *hw, int vector)
|
||||
{
|
||||
struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg;
|
||||
|
||||
cfg = hw->common_cfg;
|
||||
vp_iowrite16(vector, &cfg->msix_config);
|
||||
|
||||
return vp_ioread16(&cfg->msix_config);
|
||||
}
|
||||
|
||||
static void __iomem *get_cap_addr(struct ifcvf_hw *hw,
|
||||
struct virtio_pci_cap *cap)
|
||||
{
|
||||
@@ -158,15 +142,16 @@ next:
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
hw->nr_vring = ifc_ioread16(&hw->common_cfg->num_queues);
|
||||
hw->nr_vring = vp_ioread16(&hw->common_cfg->num_queues);
|
||||
|
||||
for (i = 0; i < hw->nr_vring; i++) {
|
||||
ifc_iowrite16(i, &hw->common_cfg->queue_select);
|
||||
notify_off = ifc_ioread16(&hw->common_cfg->queue_notify_off);
|
||||
vp_iowrite16(i, &hw->common_cfg->queue_select);
|
||||
notify_off = vp_ioread16(&hw->common_cfg->queue_notify_off);
|
||||
hw->vring[i].notify_addr = hw->notify_base +
|
||||
notify_off * hw->notify_off_multiplier;
|
||||
hw->vring[i].notify_pa = hw->notify_base_pa +
|
||||
notify_off * hw->notify_off_multiplier;
|
||||
hw->vring[i].irq = -EINVAL;
|
||||
}
|
||||
|
||||
hw->lm_cfg = hw->base[IFCVF_LM_BAR];
|
||||
@@ -176,17 +161,20 @@ next:
|
||||
hw->common_cfg, hw->notify_base, hw->isr,
|
||||
hw->dev_cfg, hw->notify_off_multiplier);
|
||||
|
||||
hw->vqs_reused_irq = -EINVAL;
|
||||
hw->config_irq = -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 ifcvf_get_status(struct ifcvf_hw *hw)
|
||||
{
|
||||
return ifc_ioread8(&hw->common_cfg->device_status);
|
||||
return vp_ioread8(&hw->common_cfg->device_status);
|
||||
}
|
||||
|
||||
void ifcvf_set_status(struct ifcvf_hw *hw, u8 status)
|
||||
{
|
||||
ifc_iowrite8(status, &hw->common_cfg->device_status);
|
||||
vp_iowrite8(status, &hw->common_cfg->device_status);
|
||||
}
|
||||
|
||||
void ifcvf_reset(struct ifcvf_hw *hw)
|
||||
@@ -214,11 +202,11 @@ u64 ifcvf_get_hw_features(struct ifcvf_hw *hw)
|
||||
u32 features_lo, features_hi;
|
||||
u64 features;
|
||||
|
||||
ifc_iowrite32(0, &cfg->device_feature_select);
|
||||
features_lo = ifc_ioread32(&cfg->device_feature);
|
||||
vp_iowrite32(0, &cfg->device_feature_select);
|
||||
features_lo = vp_ioread32(&cfg->device_feature);
|
||||
|
||||
ifc_iowrite32(1, &cfg->device_feature_select);
|
||||
features_hi = ifc_ioread32(&cfg->device_feature);
|
||||
vp_iowrite32(1, &cfg->device_feature_select);
|
||||
features_hi = vp_ioread32(&cfg->device_feature);
|
||||
|
||||
features = ((u64)features_hi << 32) | features_lo;
|
||||
|
||||
@@ -271,12 +259,12 @@ void ifcvf_read_dev_config(struct ifcvf_hw *hw, u64 offset,
|
||||
|
||||
WARN_ON(offset + length > hw->config_size);
|
||||
do {
|
||||
old_gen = ifc_ioread8(&hw->common_cfg->config_generation);
|
||||
old_gen = vp_ioread8(&hw->common_cfg->config_generation);
|
||||
p = dst;
|
||||
for (i = 0; i < length; i++)
|
||||
*p++ = ifc_ioread8(hw->dev_cfg + offset + i);
|
||||
*p++ = vp_ioread8(hw->dev_cfg + offset + i);
|
||||
|
||||
new_gen = ifc_ioread8(&hw->common_cfg->config_generation);
|
||||
new_gen = vp_ioread8(&hw->common_cfg->config_generation);
|
||||
} while (old_gen != new_gen);
|
||||
}
|
||||
|
||||
@@ -289,18 +277,18 @@ void ifcvf_write_dev_config(struct ifcvf_hw *hw, u64 offset,
|
||||
p = src;
|
||||
WARN_ON(offset + length > hw->config_size);
|
||||
for (i = 0; i < length; i++)
|
||||
ifc_iowrite8(*p++, hw->dev_cfg + offset + i);
|
||||
vp_iowrite8(*p++, hw->dev_cfg + offset + i);
|
||||
}
|
||||
|
||||
static void ifcvf_set_features(struct ifcvf_hw *hw, u64 features)
|
||||
{
|
||||
struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg;
|
||||
|
||||
ifc_iowrite32(0, &cfg->guest_feature_select);
|
||||
ifc_iowrite32((u32)features, &cfg->guest_feature);
|
||||
vp_iowrite32(0, &cfg->guest_feature_select);
|
||||
vp_iowrite32((u32)features, &cfg->guest_feature);
|
||||
|
||||
ifc_iowrite32(1, &cfg->guest_feature_select);
|
||||
ifc_iowrite32(features >> 32, &cfg->guest_feature);
|
||||
vp_iowrite32(1, &cfg->guest_feature_select);
|
||||
vp_iowrite32(features >> 32, &cfg->guest_feature);
|
||||
}
|
||||
|
||||
static int ifcvf_config_features(struct ifcvf_hw *hw)
|
||||
@@ -329,7 +317,7 @@ u16 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid)
|
||||
ifcvf_lm = (struct ifcvf_lm_cfg __iomem *)hw->lm_cfg;
|
||||
q_pair_id = qid / hw->nr_vring;
|
||||
avail_idx_addr = &ifcvf_lm->vring_lm_cfg[q_pair_id].idx_addr[qid % 2];
|
||||
last_avail_idx = ifc_ioread16(avail_idx_addr);
|
||||
last_avail_idx = vp_ioread16(avail_idx_addr);
|
||||
|
||||
return last_avail_idx;
|
||||
}
|
||||
@@ -344,7 +332,7 @@ int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num)
|
||||
q_pair_id = qid / hw->nr_vring;
|
||||
avail_idx_addr = &ifcvf_lm->vring_lm_cfg[q_pair_id].idx_addr[qid % 2];
|
||||
hw->vring[qid].last_avail_idx = num;
|
||||
ifc_iowrite16(num, avail_idx_addr);
|
||||
vp_iowrite16(num, avail_idx_addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -352,41 +340,23 @@ int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num)
|
||||
static int ifcvf_hw_enable(struct ifcvf_hw *hw)
|
||||
{
|
||||
struct virtio_pci_common_cfg __iomem *cfg;
|
||||
struct ifcvf_adapter *ifcvf;
|
||||
u32 i;
|
||||
|
||||
ifcvf = vf_to_adapter(hw);
|
||||
cfg = hw->common_cfg;
|
||||
ifc_iowrite16(IFCVF_MSI_CONFIG_OFF, &cfg->msix_config);
|
||||
|
||||
if (ifc_ioread16(&cfg->msix_config) == VIRTIO_MSI_NO_VECTOR) {
|
||||
IFCVF_ERR(ifcvf->pdev, "No msix vector for device config\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (i = 0; i < hw->nr_vring; i++) {
|
||||
if (!hw->vring[i].ready)
|
||||
break;
|
||||
|
||||
ifc_iowrite16(i, &cfg->queue_select);
|
||||
ifc_iowrite64_twopart(hw->vring[i].desc, &cfg->queue_desc_lo,
|
||||
vp_iowrite16(i, &cfg->queue_select);
|
||||
vp_iowrite64_twopart(hw->vring[i].desc, &cfg->queue_desc_lo,
|
||||
&cfg->queue_desc_hi);
|
||||
ifc_iowrite64_twopart(hw->vring[i].avail, &cfg->queue_avail_lo,
|
||||
vp_iowrite64_twopart(hw->vring[i].avail, &cfg->queue_avail_lo,
|
||||
&cfg->queue_avail_hi);
|
||||
ifc_iowrite64_twopart(hw->vring[i].used, &cfg->queue_used_lo,
|
||||
vp_iowrite64_twopart(hw->vring[i].used, &cfg->queue_used_lo,
|
||||
&cfg->queue_used_hi);
|
||||
ifc_iowrite16(hw->vring[i].size, &cfg->queue_size);
|
||||
ifc_iowrite16(i + IFCVF_MSI_QUEUE_OFF, &cfg->queue_msix_vector);
|
||||
|
||||
if (ifc_ioread16(&cfg->queue_msix_vector) ==
|
||||
VIRTIO_MSI_NO_VECTOR) {
|
||||
IFCVF_ERR(ifcvf->pdev,
|
||||
"No msix vector for queue %u\n", i);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
vp_iowrite16(hw->vring[i].size, &cfg->queue_size);
|
||||
ifcvf_set_vq_state(hw, i, hw->vring[i].last_avail_idx);
|
||||
ifc_iowrite16(1, &cfg->queue_enable);
|
||||
vp_iowrite16(1, &cfg->queue_enable);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -394,18 +364,12 @@ static int ifcvf_hw_enable(struct ifcvf_hw *hw)
|
||||
|
||||
static void ifcvf_hw_disable(struct ifcvf_hw *hw)
|
||||
{
|
||||
struct virtio_pci_common_cfg __iomem *cfg;
|
||||
u32 i;
|
||||
|
||||
cfg = hw->common_cfg;
|
||||
ifc_iowrite16(VIRTIO_MSI_NO_VECTOR, &cfg->msix_config);
|
||||
|
||||
ifcvf_set_config_vector(hw, VIRTIO_MSI_NO_VECTOR);
|
||||
for (i = 0; i < hw->nr_vring; i++) {
|
||||
ifc_iowrite16(i, &cfg->queue_select);
|
||||
ifc_iowrite16(VIRTIO_MSI_NO_VECTOR, &cfg->queue_msix_vector);
|
||||
ifcvf_set_vq_vector(hw, i, VIRTIO_MSI_NO_VECTOR);
|
||||
}
|
||||
|
||||
ifc_ioread16(&cfg->queue_msix_vector);
|
||||
}
|
||||
|
||||
int ifcvf_start_hw(struct ifcvf_hw *hw)
|
||||
@@ -433,5 +397,5 @@ void ifcvf_stop_hw(struct ifcvf_hw *hw)
|
||||
|
||||
void ifcvf_notify_queue(struct ifcvf_hw *hw, u16 qid)
|
||||
{
|
||||
ifc_iowrite16(qid, hw->vring[qid].notify_addr);
|
||||
vp_iowrite16(qid, hw->vring[qid].notify_addr);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <linux/pci.h>
|
||||
#include <linux/pci_regs.h>
|
||||
#include <linux/vdpa.h>
|
||||
#include <linux/virtio_pci_modern.h>
|
||||
#include <uapi/linux/virtio_net.h>
|
||||
#include <uapi/linux/virtio_blk.h>
|
||||
#include <uapi/linux/virtio_config.h>
|
||||
@@ -27,8 +28,6 @@
|
||||
|
||||
#define IFCVF_QUEUE_ALIGNMENT PAGE_SIZE
|
||||
#define IFCVF_QUEUE_MAX 32768
|
||||
#define IFCVF_MSI_CONFIG_OFF 0
|
||||
#define IFCVF_MSI_QUEUE_OFF 1
|
||||
#define IFCVF_PCI_MAX_RESOURCE 6
|
||||
|
||||
#define IFCVF_LM_CFG_SIZE 0x40
|
||||
@@ -42,6 +41,13 @@
|
||||
#define ifcvf_private_to_vf(adapter) \
|
||||
(&((struct ifcvf_adapter *)adapter)->vf)
|
||||
|
||||
/* all vqs and config interrupt has its own vector */
|
||||
#define MSIX_VECTOR_PER_VQ_AND_CONFIG 1
|
||||
/* all vqs share a vector, and config interrupt has a separate vector */
|
||||
#define MSIX_VECTOR_SHARED_VQ_AND_CONFIG 2
|
||||
/* all vqs and config interrupt share a vector */
|
||||
#define MSIX_VECTOR_DEV_SHARED 3
|
||||
|
||||
struct vring_info {
|
||||
u64 desc;
|
||||
u64 avail;
|
||||
@@ -60,25 +66,27 @@ struct ifcvf_hw {
|
||||
u8 __iomem *isr;
|
||||
/* Live migration */
|
||||
u8 __iomem *lm_cfg;
|
||||
u16 nr_vring;
|
||||
/* Notification bar number */
|
||||
u8 notify_bar;
|
||||
u8 msix_vector_status;
|
||||
/* virtio-net or virtio-blk device config size */
|
||||
u32 config_size;
|
||||
/* Notificaiton bar address */
|
||||
void __iomem *notify_base;
|
||||
phys_addr_t notify_base_pa;
|
||||
u32 notify_off_multiplier;
|
||||
u32 dev_type;
|
||||
u64 req_features;
|
||||
u64 hw_features;
|
||||
u32 dev_type;
|
||||
struct virtio_pci_common_cfg __iomem *common_cfg;
|
||||
void __iomem *dev_cfg;
|
||||
struct vring_info vring[IFCVF_MAX_QUEUES];
|
||||
void __iomem * const *base;
|
||||
char config_msix_name[256];
|
||||
struct vdpa_callback config_cb;
|
||||
unsigned int config_irq;
|
||||
/* virtio-net or virtio-blk device config size */
|
||||
u32 config_size;
|
||||
int config_irq;
|
||||
int vqs_reused_irq;
|
||||
u16 nr_vring;
|
||||
};
|
||||
|
||||
struct ifcvf_adapter {
|
||||
@@ -123,4 +131,6 @@ int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num);
|
||||
struct ifcvf_adapter *vf_to_adapter(struct ifcvf_hw *hw);
|
||||
int ifcvf_probed_virtio_net(struct ifcvf_hw *hw);
|
||||
u32 ifcvf_get_config_size(struct ifcvf_hw *hw);
|
||||
u16 ifcvf_set_vq_vector(struct ifcvf_hw *hw, u16 qid, int vector);
|
||||
u16 ifcvf_set_config_vector(struct ifcvf_hw *hw, int vector);
|
||||
#endif /* _IFCVF_H_ */
|
||||
|
||||
@@ -27,7 +27,7 @@ static irqreturn_t ifcvf_config_changed(int irq, void *arg)
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static irqreturn_t ifcvf_intr_handler(int irq, void *arg)
|
||||
static irqreturn_t ifcvf_vq_intr_handler(int irq, void *arg)
|
||||
{
|
||||
struct vring_info *vring = arg;
|
||||
|
||||
@@ -37,75 +37,323 @@ static irqreturn_t ifcvf_intr_handler(int irq, void *arg)
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static irqreturn_t ifcvf_vqs_reused_intr_handler(int irq, void *arg)
|
||||
{
|
||||
struct ifcvf_hw *vf = arg;
|
||||
struct vring_info *vring;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < vf->nr_vring; i++) {
|
||||
vring = &vf->vring[i];
|
||||
if (vring->cb.callback)
|
||||
vring->cb.callback(vring->cb.private);
|
||||
}
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static irqreturn_t ifcvf_dev_intr_handler(int irq, void *arg)
|
||||
{
|
||||
struct ifcvf_hw *vf = arg;
|
||||
u8 isr;
|
||||
|
||||
isr = vp_ioread8(vf->isr);
|
||||
if (isr & VIRTIO_PCI_ISR_CONFIG)
|
||||
ifcvf_config_changed(irq, arg);
|
||||
|
||||
return ifcvf_vqs_reused_intr_handler(irq, arg);
|
||||
}
|
||||
|
||||
static void ifcvf_free_irq_vectors(void *data)
|
||||
{
|
||||
pci_free_irq_vectors(data);
|
||||
}
|
||||
|
||||
static void ifcvf_free_irq(struct ifcvf_adapter *adapter, int queues)
|
||||
static void ifcvf_free_per_vq_irq(struct ifcvf_adapter *adapter)
|
||||
{
|
||||
struct pci_dev *pdev = adapter->pdev;
|
||||
struct ifcvf_hw *vf = &adapter->vf;
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < queues; i++) {
|
||||
devm_free_irq(&pdev->dev, vf->vring[i].irq, &vf->vring[i]);
|
||||
vf->vring[i].irq = -EINVAL;
|
||||
for (i = 0; i < vf->nr_vring; i++) {
|
||||
if (vf->vring[i].irq != -EINVAL) {
|
||||
devm_free_irq(&pdev->dev, vf->vring[i].irq, &vf->vring[i]);
|
||||
vf->vring[i].irq = -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
devm_free_irq(&pdev->dev, vf->config_irq, vf);
|
||||
ifcvf_free_irq_vectors(pdev);
|
||||
}
|
||||
|
||||
static int ifcvf_request_irq(struct ifcvf_adapter *adapter)
|
||||
static void ifcvf_free_vqs_reused_irq(struct ifcvf_adapter *adapter)
|
||||
{
|
||||
struct pci_dev *pdev = adapter->pdev;
|
||||
struct ifcvf_hw *vf = &adapter->vf;
|
||||
int vector, i, ret, irq;
|
||||
u16 max_intr;
|
||||
|
||||
if (vf->vqs_reused_irq != -EINVAL) {
|
||||
devm_free_irq(&pdev->dev, vf->vqs_reused_irq, vf);
|
||||
vf->vqs_reused_irq = -EINVAL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void ifcvf_free_vq_irq(struct ifcvf_adapter *adapter)
|
||||
{
|
||||
struct ifcvf_hw *vf = &adapter->vf;
|
||||
|
||||
if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG)
|
||||
ifcvf_free_per_vq_irq(adapter);
|
||||
else
|
||||
ifcvf_free_vqs_reused_irq(adapter);
|
||||
}
|
||||
|
||||
static void ifcvf_free_config_irq(struct ifcvf_adapter *adapter)
|
||||
{
|
||||
struct pci_dev *pdev = adapter->pdev;
|
||||
struct ifcvf_hw *vf = &adapter->vf;
|
||||
|
||||
if (vf->config_irq == -EINVAL)
|
||||
return;
|
||||
|
||||
/* If the irq is shared by all vqs and the config interrupt,
|
||||
* it is already freed in ifcvf_free_vq_irq, so here only
|
||||
* need to free config irq when msix_vector_status != MSIX_VECTOR_DEV_SHARED
|
||||
*/
|
||||
if (vf->msix_vector_status != MSIX_VECTOR_DEV_SHARED) {
|
||||
devm_free_irq(&pdev->dev, vf->config_irq, vf);
|
||||
vf->config_irq = -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
static void ifcvf_free_irq(struct ifcvf_adapter *adapter)
|
||||
{
|
||||
struct pci_dev *pdev = adapter->pdev;
|
||||
|
||||
ifcvf_free_vq_irq(adapter);
|
||||
ifcvf_free_config_irq(adapter);
|
||||
ifcvf_free_irq_vectors(pdev);
|
||||
}
|
||||
|
||||
/* ifcvf MSIX vectors allocator, this helper tries to allocate
|
||||
* vectors for all virtqueues and the config interrupt.
|
||||
* It returns the number of allocated vectors, negative
|
||||
* return value when fails.
|
||||
*/
|
||||
static int ifcvf_alloc_vectors(struct ifcvf_adapter *adapter)
|
||||
{
|
||||
struct pci_dev *pdev = adapter->pdev;
|
||||
struct ifcvf_hw *vf = &adapter->vf;
|
||||
int max_intr, ret;
|
||||
|
||||
/* all queues and config interrupt */
|
||||
max_intr = vf->nr_vring + 1;
|
||||
ret = pci_alloc_irq_vectors(pdev, 1, max_intr, PCI_IRQ_MSIX | PCI_IRQ_AFFINITY);
|
||||
|
||||
ret = pci_alloc_irq_vectors(pdev, max_intr,
|
||||
max_intr, PCI_IRQ_MSIX);
|
||||
if (ret < 0) {
|
||||
IFCVF_ERR(pdev, "Failed to alloc IRQ vectors\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ret < max_intr)
|
||||
IFCVF_INFO(pdev,
|
||||
"Requested %u vectors, however only %u allocated, lower performance\n",
|
||||
max_intr, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ifcvf_request_per_vq_irq(struct ifcvf_adapter *adapter)
|
||||
{
|
||||
struct pci_dev *pdev = adapter->pdev;
|
||||
struct ifcvf_hw *vf = &adapter->vf;
|
||||
int i, vector, ret, irq;
|
||||
|
||||
vf->vqs_reused_irq = -EINVAL;
|
||||
for (i = 0; i < vf->nr_vring; i++) {
|
||||
snprintf(vf->vring[i].msix_name, 256, "ifcvf[%s]-%d\n", pci_name(pdev), i);
|
||||
vector = i;
|
||||
irq = pci_irq_vector(pdev, vector);
|
||||
ret = devm_request_irq(&pdev->dev, irq,
|
||||
ifcvf_vq_intr_handler, 0,
|
||||
vf->vring[i].msix_name,
|
||||
&vf->vring[i]);
|
||||
if (ret) {
|
||||
IFCVF_ERR(pdev, "Failed to request irq for vq %d\n", i);
|
||||
goto err;
|
||||
}
|
||||
|
||||
vf->vring[i].irq = irq;
|
||||
ret = ifcvf_set_vq_vector(vf, i, vector);
|
||||
if (ret == VIRTIO_MSI_NO_VECTOR) {
|
||||
IFCVF_ERR(pdev, "No msix vector for vq %u\n", i);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
err:
|
||||
ifcvf_free_irq(adapter);
|
||||
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
static int ifcvf_request_vqs_reused_irq(struct ifcvf_adapter *adapter)
|
||||
{
|
||||
struct pci_dev *pdev = adapter->pdev;
|
||||
struct ifcvf_hw *vf = &adapter->vf;
|
||||
int i, vector, ret, irq;
|
||||
|
||||
vector = 0;
|
||||
snprintf(vf->vring[0].msix_name, 256, "ifcvf[%s]-vqs-reused-irq\n", pci_name(pdev));
|
||||
irq = pci_irq_vector(pdev, vector);
|
||||
ret = devm_request_irq(&pdev->dev, irq,
|
||||
ifcvf_vqs_reused_intr_handler, 0,
|
||||
vf->vring[0].msix_name, vf);
|
||||
if (ret) {
|
||||
IFCVF_ERR(pdev, "Failed to request reused irq for the device\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
vf->vqs_reused_irq = irq;
|
||||
for (i = 0; i < vf->nr_vring; i++) {
|
||||
vf->vring[i].irq = -EINVAL;
|
||||
ret = ifcvf_set_vq_vector(vf, i, vector);
|
||||
if (ret == VIRTIO_MSI_NO_VECTOR) {
|
||||
IFCVF_ERR(pdev, "No msix vector for vq %u\n", i);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
err:
|
||||
ifcvf_free_irq(adapter);
|
||||
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
static int ifcvf_request_dev_irq(struct ifcvf_adapter *adapter)
|
||||
{
|
||||
struct pci_dev *pdev = adapter->pdev;
|
||||
struct ifcvf_hw *vf = &adapter->vf;
|
||||
int i, vector, ret, irq;
|
||||
|
||||
vector = 0;
|
||||
snprintf(vf->vring[0].msix_name, 256, "ifcvf[%s]-dev-irq\n", pci_name(pdev));
|
||||
irq = pci_irq_vector(pdev, vector);
|
||||
ret = devm_request_irq(&pdev->dev, irq,
|
||||
ifcvf_dev_intr_handler, 0,
|
||||
vf->vring[0].msix_name, vf);
|
||||
if (ret) {
|
||||
IFCVF_ERR(pdev, "Failed to request irq for the device\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
vf->vqs_reused_irq = irq;
|
||||
for (i = 0; i < vf->nr_vring; i++) {
|
||||
vf->vring[i].irq = -EINVAL;
|
||||
ret = ifcvf_set_vq_vector(vf, i, vector);
|
||||
if (ret == VIRTIO_MSI_NO_VECTOR) {
|
||||
IFCVF_ERR(pdev, "No msix vector for vq %u\n", i);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
vf->config_irq = irq;
|
||||
ret = ifcvf_set_config_vector(vf, vector);
|
||||
if (ret == VIRTIO_MSI_NO_VECTOR) {
|
||||
IFCVF_ERR(pdev, "No msix vector for device config\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
err:
|
||||
ifcvf_free_irq(adapter);
|
||||
|
||||
return -EFAULT;
|
||||
|
||||
}
|
||||
|
||||
static int ifcvf_request_vq_irq(struct ifcvf_adapter *adapter)
|
||||
{
|
||||
struct ifcvf_hw *vf = &adapter->vf;
|
||||
int ret;
|
||||
|
||||
if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG)
|
||||
ret = ifcvf_request_per_vq_irq(adapter);
|
||||
else
|
||||
ret = ifcvf_request_vqs_reused_irq(adapter);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ifcvf_request_config_irq(struct ifcvf_adapter *adapter)
|
||||
{
|
||||
struct pci_dev *pdev = adapter->pdev;
|
||||
struct ifcvf_hw *vf = &adapter->vf;
|
||||
int config_vector, ret;
|
||||
|
||||
if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED)
|
||||
return 0;
|
||||
|
||||
if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG)
|
||||
/* vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector for config interrupt */
|
||||
config_vector = vf->nr_vring;
|
||||
|
||||
if (vf->msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG)
|
||||
/* vector 0 for vqs and 1 for config interrupt */
|
||||
config_vector = 1;
|
||||
|
||||
snprintf(vf->config_msix_name, 256, "ifcvf[%s]-config\n",
|
||||
pci_name(pdev));
|
||||
vector = 0;
|
||||
vf->config_irq = pci_irq_vector(pdev, vector);
|
||||
vf->config_irq = pci_irq_vector(pdev, config_vector);
|
||||
ret = devm_request_irq(&pdev->dev, vf->config_irq,
|
||||
ifcvf_config_changed, 0,
|
||||
vf->config_msix_name, vf);
|
||||
if (ret) {
|
||||
IFCVF_ERR(pdev, "Failed to request config irq\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = ifcvf_set_config_vector(vf, config_vector);
|
||||
if (ret == VIRTIO_MSI_NO_VECTOR) {
|
||||
IFCVF_ERR(pdev, "No msix vector for device config\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
err:
|
||||
ifcvf_free_irq(adapter);
|
||||
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
static int ifcvf_request_irq(struct ifcvf_adapter *adapter)
|
||||
{
|
||||
struct ifcvf_hw *vf = &adapter->vf;
|
||||
int nvectors, ret, max_intr;
|
||||
|
||||
nvectors = ifcvf_alloc_vectors(adapter);
|
||||
if (nvectors <= 0)
|
||||
return -EFAULT;
|
||||
|
||||
vf->msix_vector_status = MSIX_VECTOR_PER_VQ_AND_CONFIG;
|
||||
max_intr = vf->nr_vring + 1;
|
||||
if (nvectors < max_intr)
|
||||
vf->msix_vector_status = MSIX_VECTOR_SHARED_VQ_AND_CONFIG;
|
||||
|
||||
if (nvectors == 1) {
|
||||
vf->msix_vector_status = MSIX_VECTOR_DEV_SHARED;
|
||||
ret = ifcvf_request_dev_irq(adapter);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (i = 0; i < vf->nr_vring; i++) {
|
||||
snprintf(vf->vring[i].msix_name, 256, "ifcvf[%s]-%d\n",
|
||||
pci_name(pdev), i);
|
||||
vector = i + IFCVF_MSI_QUEUE_OFF;
|
||||
irq = pci_irq_vector(pdev, vector);
|
||||
ret = devm_request_irq(&pdev->dev, irq,
|
||||
ifcvf_intr_handler, 0,
|
||||
vf->vring[i].msix_name,
|
||||
&vf->vring[i]);
|
||||
if (ret) {
|
||||
IFCVF_ERR(pdev,
|
||||
"Failed to request irq for vq %d\n", i);
|
||||
ifcvf_free_irq(adapter, i);
|
||||
ret = ifcvf_request_vq_irq(adapter);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
ret = ifcvf_request_config_irq(adapter);
|
||||
|
||||
vf->vring[i].irq = irq;
|
||||
}
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -263,7 +511,7 @@ static int ifcvf_vdpa_reset(struct vdpa_device *vdpa_dev)
|
||||
|
||||
if (status_old & VIRTIO_CONFIG_S_DRIVER_OK) {
|
||||
ifcvf_stop_datapath(adapter);
|
||||
ifcvf_free_irq(adapter, vf->nr_vring);
|
||||
ifcvf_free_irq(adapter);
|
||||
}
|
||||
|
||||
ifcvf_reset_vring(adapter);
|
||||
@@ -348,7 +596,7 @@ static u32 ifcvf_vdpa_get_generation(struct vdpa_device *vdpa_dev)
|
||||
{
|
||||
struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev);
|
||||
|
||||
return ioread8(&vf->common_cfg->config_generation);
|
||||
return vp_ioread8(&vf->common_cfg->config_generation);
|
||||
}
|
||||
|
||||
static u32 ifcvf_vdpa_get_device_id(struct vdpa_device *vdpa_dev)
|
||||
@@ -410,7 +658,10 @@ static int ifcvf_vdpa_get_vq_irq(struct vdpa_device *vdpa_dev,
|
||||
{
|
||||
struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev);
|
||||
|
||||
return vf->vring[qid].irq;
|
||||
if (vf->vqs_reused_irq < 0)
|
||||
return vf->vring[qid].irq;
|
||||
else
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static struct vdpa_notification_area ifcvf_get_vq_notification(struct vdpa_device *vdpa_dev,
|
||||
|
||||
@@ -1475,7 +1475,7 @@ static virtio_net_ctrl_ack handle_ctrl_mac(struct mlx5_vdpa_dev *mvdev, u8 cmd)
|
||||
virtio_net_ctrl_ack status = VIRTIO_NET_ERR;
|
||||
struct mlx5_core_dev *pfmdev;
|
||||
size_t read;
|
||||
u8 mac[ETH_ALEN];
|
||||
u8 mac[ETH_ALEN], mac_back[ETH_ALEN];
|
||||
|
||||
pfmdev = pci_get_drvdata(pci_physfn(mvdev->mdev->pdev));
|
||||
switch (cmd) {
|
||||
@@ -1489,6 +1489,9 @@ static virtio_net_ctrl_ack handle_ctrl_mac(struct mlx5_vdpa_dev *mvdev, u8 cmd)
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_zero_ether_addr(mac))
|
||||
break;
|
||||
|
||||
if (!is_zero_ether_addr(ndev->config.mac)) {
|
||||
if (mlx5_mpfs_del_mac(pfmdev, ndev->config.mac)) {
|
||||
mlx5_vdpa_warn(mvdev, "failed to delete old MAC %pM from MPFS table\n",
|
||||
@@ -1503,7 +1506,47 @@ static virtio_net_ctrl_ack handle_ctrl_mac(struct mlx5_vdpa_dev *mvdev, u8 cmd)
|
||||
break;
|
||||
}
|
||||
|
||||
/* backup the original mac address so that if failed to add the forward rules
|
||||
* we could restore it
|
||||
*/
|
||||
memcpy(mac_back, ndev->config.mac, ETH_ALEN);
|
||||
|
||||
memcpy(ndev->config.mac, mac, ETH_ALEN);
|
||||
|
||||
/* Need recreate the flow table entry, so that the packet could forward back
|
||||
*/
|
||||
remove_fwd_to_tir(ndev);
|
||||
|
||||
if (add_fwd_to_tir(ndev)) {
|
||||
mlx5_vdpa_warn(mvdev, "failed to insert forward rules, try to restore\n");
|
||||
|
||||
/* Although it hardly run here, we still need double check */
|
||||
if (is_zero_ether_addr(mac_back)) {
|
||||
mlx5_vdpa_warn(mvdev, "restore mac failed: Original MAC is zero\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Try to restore original mac address to MFPS table, and try to restore
|
||||
* the forward rule entry.
|
||||
*/
|
||||
if (mlx5_mpfs_del_mac(pfmdev, ndev->config.mac)) {
|
||||
mlx5_vdpa_warn(mvdev, "restore mac failed: delete MAC %pM from MPFS table failed\n",
|
||||
ndev->config.mac);
|
||||
}
|
||||
|
||||
if (mlx5_mpfs_add_mac(pfmdev, mac_back)) {
|
||||
mlx5_vdpa_warn(mvdev, "restore mac failed: insert old MAC %pM into MPFS table failed\n",
|
||||
mac_back);
|
||||
}
|
||||
|
||||
memcpy(ndev->config.mac, mac_back, ETH_ALEN);
|
||||
|
||||
if (add_fwd_to_tir(ndev))
|
||||
mlx5_vdpa_warn(mvdev, "restore forward rules failed: insert forward rules failed\n");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
status = VIRTIO_NET_OK;
|
||||
break;
|
||||
|
||||
@@ -1669,7 +1712,7 @@ static void mlx5_vdpa_kick_vq(struct vdpa_device *vdev, u16 idx)
|
||||
return;
|
||||
|
||||
if (unlikely(is_ctrl_vq_idx(mvdev, idx))) {
|
||||
if (!mvdev->cvq.ready)
|
||||
if (!mvdev->wq || !mvdev->cvq.ready)
|
||||
return;
|
||||
|
||||
wqent = kzalloc(sizeof(*wqent), GFP_ATOMIC);
|
||||
@@ -2565,6 +2608,28 @@ static int event_handler(struct notifier_block *nb, unsigned long event, void *p
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int config_func_mtu(struct mlx5_core_dev *mdev, u16 mtu)
|
||||
{
|
||||
int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in);
|
||||
void *in;
|
||||
int err;
|
||||
|
||||
in = kvzalloc(inlen, GFP_KERNEL);
|
||||
if (!in)
|
||||
return -ENOMEM;
|
||||
|
||||
MLX5_SET(modify_nic_vport_context_in, in, field_select.mtu, 1);
|
||||
MLX5_SET(modify_nic_vport_context_in, in, nic_vport_context.mtu,
|
||||
mtu + MLX5V_ETH_HARD_MTU);
|
||||
MLX5_SET(modify_nic_vport_context_in, in, opcode,
|
||||
MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
|
||||
|
||||
err = mlx5_cmd_exec_in(mdev, modify_nic_vport_context, in);
|
||||
|
||||
kvfree(in);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
|
||||
const struct vdpa_dev_set_config *add_config)
|
||||
{
|
||||
@@ -2624,6 +2689,13 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
|
||||
init_mvqs(ndev);
|
||||
mutex_init(&ndev->reslock);
|
||||
config = &ndev->config;
|
||||
|
||||
if (add_config->mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU)) {
|
||||
err = config_func_mtu(mdev, add_config->net.mtu);
|
||||
if (err)
|
||||
goto err_mtu;
|
||||
}
|
||||
|
||||
err = query_mtu(mdev, &mtu);
|
||||
if (err)
|
||||
goto err_mtu;
|
||||
@@ -2707,9 +2779,12 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *
|
||||
struct mlx5_vdpa_mgmtdev *mgtdev = container_of(v_mdev, struct mlx5_vdpa_mgmtdev, mgtdev);
|
||||
struct mlx5_vdpa_dev *mvdev = to_mvdev(dev);
|
||||
struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev);
|
||||
struct workqueue_struct *wq;
|
||||
|
||||
mlx5_notifier_unregister(mvdev->mdev, &ndev->nb);
|
||||
destroy_workqueue(mvdev->wq);
|
||||
wq = mvdev->wq;
|
||||
mvdev->wq = NULL;
|
||||
destroy_workqueue(wq);
|
||||
_vdpa_unregister_device(dev);
|
||||
mgtdev->ndev = NULL;
|
||||
}
|
||||
@@ -2741,7 +2816,8 @@ static int mlx5v_probe(struct auxiliary_device *adev,
|
||||
mgtdev->mgtdev.device = mdev->device;
|
||||
mgtdev->mgtdev.id_table = id_table;
|
||||
mgtdev->mgtdev.config_attr_mask = BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MACADDR) |
|
||||
BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP);
|
||||
BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP) |
|
||||
BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU);
|
||||
mgtdev->mgtdev.max_supported_vqs =
|
||||
MLX5_CAP_DEV_VDPA_EMULATION(mdev, max_num_virtio_queues) + 1;
|
||||
mgtdev->mgtdev.supported_features = get_supported_features(mdev);
|
||||
|
||||
@@ -232,7 +232,7 @@ static int vdpa_name_match(struct device *dev, const void *data)
|
||||
return (strcmp(dev_name(&vdev->dev), data) == 0);
|
||||
}
|
||||
|
||||
static int __vdpa_register_device(struct vdpa_device *vdev, int nvqs)
|
||||
static int __vdpa_register_device(struct vdpa_device *vdev, u32 nvqs)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
@@ -257,7 +257,7 @@ static int __vdpa_register_device(struct vdpa_device *vdev, int nvqs)
|
||||
*
|
||||
* Return: Returns an error when fail to add device to vDPA bus
|
||||
*/
|
||||
int _vdpa_register_device(struct vdpa_device *vdev, int nvqs)
|
||||
int _vdpa_register_device(struct vdpa_device *vdev, u32 nvqs)
|
||||
{
|
||||
if (!vdev->mdev)
|
||||
return -EINVAL;
|
||||
@@ -274,7 +274,7 @@ EXPORT_SYMBOL_GPL(_vdpa_register_device);
|
||||
*
|
||||
* Return: Returns an error when fail to add to vDPA bus
|
||||
*/
|
||||
int vdpa_register_device(struct vdpa_device *vdev, int nvqs)
|
||||
int vdpa_register_device(struct vdpa_device *vdev, u32 nvqs)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
||||
@@ -62,8 +62,12 @@ int vhost_iotlb_add_range_ctx(struct vhost_iotlb *iotlb,
|
||||
*/
|
||||
if (start == 0 && last == ULONG_MAX) {
|
||||
u64 mid = last / 2;
|
||||
int err = vhost_iotlb_add_range_ctx(iotlb, start, mid, addr,
|
||||
perm, opaque);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
vhost_iotlb_add_range_ctx(iotlb, start, mid, addr, perm, opaque);
|
||||
addr += mid + 1;
|
||||
start = mid + 1;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ struct vhost_vdpa {
|
||||
struct device dev;
|
||||
struct cdev cdev;
|
||||
atomic_t opened;
|
||||
int nvqs;
|
||||
u32 nvqs;
|
||||
int virtio_id;
|
||||
int minor;
|
||||
struct eventfd_ctx *config_ctx;
|
||||
@@ -97,8 +97,11 @@ static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid)
|
||||
return;
|
||||
|
||||
irq = ops->get_vq_irq(vdpa, qid);
|
||||
if (irq < 0)
|
||||
return;
|
||||
|
||||
irq_bypass_unregister_producer(&vq->call_ctx.producer);
|
||||
if (!vq->call_ctx.ctx || irq < 0)
|
||||
if (!vq->call_ctx.ctx)
|
||||
return;
|
||||
|
||||
vq->call_ctx.producer.token = vq->call_ctx.ctx;
|
||||
@@ -158,7 +161,8 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
|
||||
struct vdpa_device *vdpa = v->vdpa;
|
||||
const struct vdpa_config_ops *ops = vdpa->config;
|
||||
u8 status, status_old;
|
||||
int ret, nvqs = v->nvqs;
|
||||
u32 nvqs = v->nvqs;
|
||||
int ret;
|
||||
u16 i;
|
||||
|
||||
if (copy_from_user(&status, statusp, sizeof(status)))
|
||||
@@ -355,6 +359,30 @@ static long vhost_vdpa_get_iova_range(struct vhost_vdpa *v, u32 __user *argp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long vhost_vdpa_get_config_size(struct vhost_vdpa *v, u32 __user *argp)
|
||||
{
|
||||
struct vdpa_device *vdpa = v->vdpa;
|
||||
const struct vdpa_config_ops *ops = vdpa->config;
|
||||
u32 size;
|
||||
|
||||
size = ops->get_config_size(vdpa);
|
||||
|
||||
if (copy_to_user(argp, &size, sizeof(size)))
|
||||
return -EFAULT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long vhost_vdpa_get_vqs_count(struct vhost_vdpa *v, u32 __user *argp)
|
||||
{
|
||||
struct vdpa_device *vdpa = v->vdpa;
|
||||
|
||||
if (copy_to_user(argp, &vdpa->nvqs, sizeof(vdpa->nvqs)))
|
||||
return -EFAULT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
|
||||
void __user *argp)
|
||||
{
|
||||
@@ -492,6 +520,12 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
|
||||
case VHOST_VDPA_GET_IOVA_RANGE:
|
||||
r = vhost_vdpa_get_iova_range(v, argp);
|
||||
break;
|
||||
case VHOST_VDPA_GET_CONFIG_SIZE:
|
||||
r = vhost_vdpa_get_config_size(v, argp);
|
||||
break;
|
||||
case VHOST_VDPA_GET_VQS_COUNT:
|
||||
r = vhost_vdpa_get_vqs_count(v, argp);
|
||||
break;
|
||||
default:
|
||||
r = vhost_dev_ioctl(&v->vdev, cmd, argp);
|
||||
if (r == -ENOIOCTLCMD)
|
||||
@@ -948,7 +982,8 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep)
|
||||
struct vhost_vdpa *v;
|
||||
struct vhost_dev *dev;
|
||||
struct vhost_virtqueue **vqs;
|
||||
int nvqs, i, r, opened;
|
||||
int r, opened;
|
||||
u32 i, nvqs;
|
||||
|
||||
v = container_of(inode->i_cdev, struct vhost_vdpa, cdev);
|
||||
|
||||
@@ -1001,7 +1036,7 @@ err:
|
||||
|
||||
static void vhost_vdpa_clean_irq(struct vhost_vdpa *v)
|
||||
{
|
||||
int i;
|
||||
u32 i;
|
||||
|
||||
for (i = 0; i < v->nvqs; i++)
|
||||
vhost_vdpa_unsetup_vq_irq(v, i);
|
||||
|
||||
@@ -2550,8 +2550,9 @@ bool vhost_enable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
|
||||
&vq->avail->idx, r);
|
||||
return false;
|
||||
}
|
||||
vq->avail_idx = vhost16_to_cpu(vq, avail_idx);
|
||||
|
||||
return vhost16_to_cpu(vq, avail_idx) != vq->avail_idx;
|
||||
return vq->avail_idx != vq->last_avail_idx;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vhost_enable_notify);
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ config VIRTIO_BALLOON
|
||||
|
||||
config VIRTIO_MEM
|
||||
tristate "Virtio mem driver"
|
||||
depends on X86_64
|
||||
depends on X86_64 || ARM64
|
||||
depends on VIRTIO
|
||||
depends on MEMORY_HOTPLUG
|
||||
depends on MEMORY_HOTREMOVE
|
||||
@@ -115,8 +115,9 @@ config VIRTIO_MEM
|
||||
This driver provides access to virtio-mem paravirtualized memory
|
||||
devices, allowing to hotplug and hotunplug memory.
|
||||
|
||||
This driver was only tested under x86-64, but should theoretically
|
||||
work on all architectures that support memory hotplug and hotremove.
|
||||
This driver was only tested under x86-64 and arm64, but should
|
||||
theoretically work on all architectures that support memory hotplug
|
||||
and hotremove.
|
||||
|
||||
If unsure, say M.
|
||||
|
||||
|
||||
@@ -526,8 +526,9 @@ int virtio_device_restore(struct virtio_device *dev)
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Finally, tell the device we're all set */
|
||||
virtio_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
|
||||
/* If restore didn't do it, mark device DRIVER_OK ourselves. */
|
||||
if (!(dev->config->get_status(dev) & VIRTIO_CONFIG_S_DRIVER_OK))
|
||||
virtio_device_ready(dev);
|
||||
|
||||
virtio_config_enable(dev);
|
||||
|
||||
|
||||
@@ -24,46 +24,17 @@ MODULE_PARM_DESC(force_legacy,
|
||||
"Force legacy mode for transitional virtio 1 devices");
|
||||
#endif
|
||||
|
||||
/* disable irq handlers */
|
||||
void vp_disable_cbs(struct virtio_device *vdev)
|
||||
/* wait for pending irq handlers */
|
||||
void vp_synchronize_vectors(struct virtio_device *vdev)
|
||||
{
|
||||
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
|
||||
int i;
|
||||
|
||||
if (vp_dev->intx_enabled) {
|
||||
/*
|
||||
* The below synchronize() guarantees that any
|
||||
* interrupt for this line arriving after
|
||||
* synchronize_irq() has completed is guaranteed to see
|
||||
* intx_soft_enabled == false.
|
||||
*/
|
||||
WRITE_ONCE(vp_dev->intx_soft_enabled, false);
|
||||
if (vp_dev->intx_enabled)
|
||||
synchronize_irq(vp_dev->pci_dev->irq);
|
||||
}
|
||||
|
||||
for (i = 0; i < vp_dev->msix_vectors; ++i)
|
||||
disable_irq(pci_irq_vector(vp_dev->pci_dev, i));
|
||||
}
|
||||
|
||||
/* enable irq handlers */
|
||||
void vp_enable_cbs(struct virtio_device *vdev)
|
||||
{
|
||||
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
|
||||
int i;
|
||||
|
||||
if (vp_dev->intx_enabled) {
|
||||
disable_irq(vp_dev->pci_dev->irq);
|
||||
/*
|
||||
* The above disable_irq() provides TSO ordering and
|
||||
* as such promotes the below store to store-release.
|
||||
*/
|
||||
WRITE_ONCE(vp_dev->intx_soft_enabled, true);
|
||||
enable_irq(vp_dev->pci_dev->irq);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < vp_dev->msix_vectors; ++i)
|
||||
enable_irq(pci_irq_vector(vp_dev->pci_dev, i));
|
||||
synchronize_irq(pci_irq_vector(vp_dev->pci_dev, i));
|
||||
}
|
||||
|
||||
/* the notify function used when creating a virt queue */
|
||||
@@ -113,9 +84,6 @@ static irqreturn_t vp_interrupt(int irq, void *opaque)
|
||||
struct virtio_pci_device *vp_dev = opaque;
|
||||
u8 isr;
|
||||
|
||||
if (!READ_ONCE(vp_dev->intx_soft_enabled))
|
||||
return IRQ_NONE;
|
||||
|
||||
/* reading the ISR has the effect of also clearing it so it's very
|
||||
* important to save off the value. */
|
||||
isr = ioread8(vp_dev->isr);
|
||||
@@ -173,8 +141,7 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
|
||||
snprintf(vp_dev->msix_names[v], sizeof *vp_dev->msix_names,
|
||||
"%s-config", name);
|
||||
err = request_irq(pci_irq_vector(vp_dev->pci_dev, v),
|
||||
vp_config_changed, IRQF_NO_AUTOEN,
|
||||
vp_dev->msix_names[v],
|
||||
vp_config_changed, 0, vp_dev->msix_names[v],
|
||||
vp_dev);
|
||||
if (err)
|
||||
goto error;
|
||||
@@ -193,8 +160,7 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
|
||||
snprintf(vp_dev->msix_names[v], sizeof *vp_dev->msix_names,
|
||||
"%s-virtqueues", name);
|
||||
err = request_irq(pci_irq_vector(vp_dev->pci_dev, v),
|
||||
vp_vring_interrupt, IRQF_NO_AUTOEN,
|
||||
vp_dev->msix_names[v],
|
||||
vp_vring_interrupt, 0, vp_dev->msix_names[v],
|
||||
vp_dev);
|
||||
if (err)
|
||||
goto error;
|
||||
@@ -371,7 +337,7 @@ static int vp_find_vqs_msix(struct virtio_device *vdev, unsigned nvqs,
|
||||
"%s-%s",
|
||||
dev_name(&vp_dev->vdev.dev), names[i]);
|
||||
err = request_irq(pci_irq_vector(vp_dev->pci_dev, msix_vec),
|
||||
vring_interrupt, IRQF_NO_AUTOEN,
|
||||
vring_interrupt, 0,
|
||||
vp_dev->msix_names[msix_vec],
|
||||
vqs[i]);
|
||||
if (err)
|
||||
|
||||
@@ -63,7 +63,6 @@ struct virtio_pci_device {
|
||||
/* MSI-X support */
|
||||
int msix_enabled;
|
||||
int intx_enabled;
|
||||
bool intx_soft_enabled;
|
||||
cpumask_var_t *msix_affinity_masks;
|
||||
/* Name strings for interrupts. This size should be enough,
|
||||
* and I'm too lazy to allocate each name separately. */
|
||||
@@ -102,10 +101,8 @@ static struct virtio_pci_device *to_vp_device(struct virtio_device *vdev)
|
||||
return container_of(vdev, struct virtio_pci_device, vdev);
|
||||
}
|
||||
|
||||
/* disable irq handlers */
|
||||
void vp_disable_cbs(struct virtio_device *vdev);
|
||||
/* enable irq handlers */
|
||||
void vp_enable_cbs(struct virtio_device *vdev);
|
||||
/* wait for pending irq handlers */
|
||||
void vp_synchronize_vectors(struct virtio_device *vdev);
|
||||
/* the notify function used when creating a virt queue */
|
||||
bool vp_notify(struct virtqueue *vq);
|
||||
/* the config->del_vqs() implementation */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user