net/mlx5: enhance SR-IOV detection
SR-IOV mode is currently set when dealing with VF devices. PF devices must be taken into account as well if they have active VFs. Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
This commit is contained in:
parent
96327064ab
commit
85e347db87
@ -260,7 +260,7 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
|
|||||||
int err = 0;
|
int err = 0;
|
||||||
struct ibv_context *attr_ctx = NULL;
|
struct ibv_context *attr_ctx = NULL;
|
||||||
struct ibv_device_attr device_attr;
|
struct ibv_device_attr device_attr;
|
||||||
unsigned int vf;
|
unsigned int sriov;
|
||||||
unsigned int mps;
|
unsigned int mps;
|
||||||
int idx;
|
int idx;
|
||||||
int i;
|
int i;
|
||||||
@ -303,17 +303,17 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
|
|||||||
(pci_dev->addr.devid != pci_addr.devid) ||
|
(pci_dev->addr.devid != pci_addr.devid) ||
|
||||||
(pci_dev->addr.function != pci_addr.function))
|
(pci_dev->addr.function != pci_addr.function))
|
||||||
continue;
|
continue;
|
||||||
vf = ((pci_dev->id.device_id ==
|
sriov = ((pci_dev->id.device_id ==
|
||||||
PCI_DEVICE_ID_MELLANOX_CONNECTX4VF) ||
|
PCI_DEVICE_ID_MELLANOX_CONNECTX4VF) ||
|
||||||
(pci_dev->id.device_id ==
|
(pci_dev->id.device_id ==
|
||||||
PCI_DEVICE_ID_MELLANOX_CONNECTX4LXVF));
|
PCI_DEVICE_ID_MELLANOX_CONNECTX4LXVF));
|
||||||
/* Multi-packet send is only supported by ConnectX-4 Lx PF. */
|
/* Multi-packet send is only supported by ConnectX-4 Lx PF. */
|
||||||
mps = (pci_dev->id.device_id ==
|
mps = (pci_dev->id.device_id ==
|
||||||
PCI_DEVICE_ID_MELLANOX_CONNECTX4LX);
|
PCI_DEVICE_ID_MELLANOX_CONNECTX4LX);
|
||||||
INFO("PCI information matches, using device \"%s\" (VF: %s,"
|
INFO("PCI information matches, using device \"%s\""
|
||||||
" MPS: %s)",
|
" (SR-IOV: %s, MPS: %s)",
|
||||||
list[i]->name,
|
list[i]->name,
|
||||||
vf ? "true" : "false",
|
sriov ? "true" : "false",
|
||||||
mps ? "true" : "false");
|
mps ? "true" : "false");
|
||||||
attr_ctx = ibv_open_device(list[i]);
|
attr_ctx = ibv_open_device(list[i]);
|
||||||
err = errno;
|
err = errno;
|
||||||
@ -351,6 +351,7 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
|
|||||||
struct ibv_exp_device_attr exp_device_attr;
|
struct ibv_exp_device_attr exp_device_attr;
|
||||||
#endif /* HAVE_EXP_QUERY_DEVICE */
|
#endif /* HAVE_EXP_QUERY_DEVICE */
|
||||||
struct ether_addr mac;
|
struct ether_addr mac;
|
||||||
|
uint16_t num_vfs = 0;
|
||||||
|
|
||||||
#ifdef HAVE_EXP_QUERY_DEVICE
|
#ifdef HAVE_EXP_QUERY_DEVICE
|
||||||
exp_device_attr.comp_mask =
|
exp_device_attr.comp_mask =
|
||||||
@ -464,7 +465,8 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
|
|||||||
priv->ind_table_max_size = RSS_INDIRECTION_TABLE_SIZE;
|
priv->ind_table_max_size = RSS_INDIRECTION_TABLE_SIZE;
|
||||||
#endif /* HAVE_EXP_QUERY_DEVICE */
|
#endif /* HAVE_EXP_QUERY_DEVICE */
|
||||||
|
|
||||||
priv->vf = vf;
|
priv_get_num_vfs(priv, &num_vfs);
|
||||||
|
priv->sriov = (num_vfs || sriov);
|
||||||
priv->mps = mps;
|
priv->mps = mps;
|
||||||
/* Allocate and register default RSS hash keys. */
|
/* Allocate and register default RSS hash keys. */
|
||||||
priv->rss_conf = rte_calloc(__func__, hash_rxq_init_n,
|
priv->rss_conf = rte_calloc(__func__, hash_rxq_init_n,
|
||||||
|
@ -104,7 +104,7 @@ struct priv {
|
|||||||
unsigned int hw_vlan_strip:1; /* VLAN stripping is supported. */
|
unsigned int hw_vlan_strip:1; /* VLAN stripping is supported. */
|
||||||
unsigned int hw_fcs_strip:1; /* FCS stripping is supported. */
|
unsigned int hw_fcs_strip:1; /* FCS stripping is supported. */
|
||||||
unsigned int hw_padding:1; /* End alignment padding is supported. */
|
unsigned int hw_padding:1; /* End alignment padding is supported. */
|
||||||
unsigned int vf:1; /* This is a VF device. */
|
unsigned int sriov:1; /* This is a VF or PF with VF devices. */
|
||||||
unsigned int mps:1; /* Whether multi-packet send is supported. */
|
unsigned int mps:1; /* Whether multi-packet send is supported. */
|
||||||
unsigned int pending_alarm:1; /* An alarm is pending. */
|
unsigned int pending_alarm:1; /* An alarm is pending. */
|
||||||
/* RX/TX queues. */
|
/* RX/TX queues. */
|
||||||
@ -172,6 +172,7 @@ struct priv *mlx5_get_priv(struct rte_eth_dev *dev);
|
|||||||
int mlx5_is_secondary(void);
|
int mlx5_is_secondary(void);
|
||||||
int priv_get_ifname(const struct priv *, char (*)[IF_NAMESIZE]);
|
int priv_get_ifname(const struct priv *, char (*)[IF_NAMESIZE]);
|
||||||
int priv_ifreq(const struct priv *, int req, struct ifreq *);
|
int priv_ifreq(const struct priv *, int req, struct ifreq *);
|
||||||
|
int priv_get_num_vfs(struct priv *, uint16_t *);
|
||||||
int priv_get_mtu(struct priv *, uint16_t *);
|
int priv_get_mtu(struct priv *, uint16_t *);
|
||||||
int priv_set_flags(struct priv *, unsigned int, unsigned int);
|
int priv_set_flags(struct priv *, unsigned int, unsigned int);
|
||||||
int mlx5_dev_configure(struct rte_eth_dev *);
|
int mlx5_dev_configure(struct rte_eth_dev *);
|
||||||
|
@ -361,6 +361,38 @@ priv_ifreq(const struct priv *priv, int req, struct ifreq *ifr)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the number of active VFs for the current device.
|
||||||
|
*
|
||||||
|
* @param[in] priv
|
||||||
|
* Pointer to private structure.
|
||||||
|
* @param[out] num_vfs
|
||||||
|
* Number of active VFs.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* 0 on success, -1 on failure and errno is set.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
priv_get_num_vfs(struct priv *priv, uint16_t *num_vfs)
|
||||||
|
{
|
||||||
|
/* The sysfs entry name depends on the operating system. */
|
||||||
|
const char **name = (const char *[]){
|
||||||
|
"device/sriov_numvfs",
|
||||||
|
"device/mlx5_num_vfs",
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
do {
|
||||||
|
unsigned long ulong_num_vfs;
|
||||||
|
|
||||||
|
ret = priv_get_sysfs_ulong(priv, *name, &ulong_num_vfs);
|
||||||
|
if (!ret)
|
||||||
|
*num_vfs = ulong_num_vfs;
|
||||||
|
} while (*(++name) && ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get device MTU.
|
* Get device MTU.
|
||||||
*
|
*
|
||||||
|
@ -507,7 +507,7 @@ tx_burst_sg(struct txq *txq, unsigned int segs, struct txq_elt *elt,
|
|||||||
}
|
}
|
||||||
/* Update SGE. */
|
/* Update SGE. */
|
||||||
sge->addr = rte_pktmbuf_mtod(buf, uintptr_t);
|
sge->addr = rte_pktmbuf_mtod(buf, uintptr_t);
|
||||||
if (txq->priv->vf)
|
if (txq->priv->sriov)
|
||||||
rte_prefetch0((volatile void *)
|
rte_prefetch0((volatile void *)
|
||||||
(uintptr_t)sge->addr);
|
(uintptr_t)sge->addr);
|
||||||
sge->length = DATA_LEN(buf);
|
sge->length = DATA_LEN(buf);
|
||||||
@ -662,7 +662,7 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
|
|||||||
length = DATA_LEN(buf);
|
length = DATA_LEN(buf);
|
||||||
/* Update element. */
|
/* Update element. */
|
||||||
elt->buf = buf;
|
elt->buf = buf;
|
||||||
if (txq->priv->vf)
|
if (txq->priv->sriov)
|
||||||
rte_prefetch0((volatile void *)
|
rte_prefetch0((volatile void *)
|
||||||
(uintptr_t)addr);
|
(uintptr_t)addr);
|
||||||
/* Prefetch next buffer data. */
|
/* Prefetch next buffer data. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user