Commit dd41cc3b authored by Matan Barak's avatar Matan Barak Committed by David S. Miller

net/mlx4: Adapt num_vfs/probed_vf params for single port VF

A new syntax is added for the module parameters num_vfs and probe_vf.

  num_vfs=p1,p2,p1+p2
  probe_bf=p1,p2,p1+p2

Where p1(2) is the number of VFs on / probed VFs for physical
port1(2) and p1+p2 is the number of dual port VFs.

Single port VFs are currently supported only when the link type
for both ports of the device is Ethernet.
Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 449fc488
...@@ -77,13 +77,17 @@ MODULE_PARM_DESC(msi_x, "attempt to use MSI-X if nonzero"); ...@@ -77,13 +77,17 @@ MODULE_PARM_DESC(msi_x, "attempt to use MSI-X if nonzero");
#endif /* CONFIG_PCI_MSI */ #endif /* CONFIG_PCI_MSI */
static int num_vfs; static uint8_t num_vfs[3] = {0, 0, 0};
module_param(num_vfs, int, 0444); static int num_vfs_argc = 3;
MODULE_PARM_DESC(num_vfs, "enable #num_vfs functions if num_vfs > 0"); module_param_array(num_vfs, byte , &num_vfs_argc, 0444);
MODULE_PARM_DESC(num_vfs, "enable #num_vfs functions if num_vfs > 0\n"
static int probe_vf; "num_vfs=port1,port2,port1+2");
module_param(probe_vf, int, 0644);
MODULE_PARM_DESC(probe_vf, "number of vfs to probe by pf driver (num_vfs > 0)"); static uint8_t probe_vf[3] = {0, 0, 0};
static int probe_vfs_argc = 3;
module_param_array(probe_vf, byte, &probe_vfs_argc, 0444);
MODULE_PARM_DESC(probe_vf, "number of vfs to probe by pf driver (num_vfs > 0)\n"
"probe_vf=port1,port2,port1+2");
int mlx4_log_num_mgm_entry_size = MLX4_DEFAULT_MGM_LOG_ENTRY_SIZE; int mlx4_log_num_mgm_entry_size = MLX4_DEFAULT_MGM_LOG_ENTRY_SIZE;
module_param_named(log_num_mgm_entry_size, module_param_named(log_num_mgm_entry_size,
...@@ -2193,7 +2197,10 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data) ...@@ -2193,7 +2197,10 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data)
struct mlx4_dev *dev; struct mlx4_dev *dev;
int err; int err;
int port; int port;
int nvfs[MLX4_MAX_PORTS + 1], prb_vf[MLX4_MAX_PORTS + 1]; int nvfs[MLX4_MAX_PORTS + 1] = {0, 0, 0};
int prb_vf[MLX4_MAX_PORTS + 1] = {0, 0, 0};
const int param_map[MLX4_MAX_PORTS + 1][MLX4_MAX_PORTS + 1] = {
{2, 0, 0}, {0, 1, 2}, {0, 1, 2} };
unsigned total_vfs = 0; unsigned total_vfs = 0;
int sriov_initialized = 0; int sriov_initialized = 0;
unsigned int i; unsigned int i;
...@@ -2211,16 +2218,17 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data) ...@@ -2211,16 +2218,17 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data)
* per port, we must limit the number of VFs to 63 (since their are * per port, we must limit the number of VFs to 63 (since their are
* 128 MACs) * 128 MACs)
*/ */
for (i = 0; i < sizeof(nvfs)/sizeof(nvfs[0]); for (i = 0; i < sizeof(nvfs)/sizeof(nvfs[0]) && i < num_vfs_argc;
total_vfs += nvfs[i], i++) { total_vfs += nvfs[param_map[num_vfs_argc - 1][i]], i++) {
nvfs[i] = i == MLX4_MAX_PORTS ? num_vfs : 0; nvfs[param_map[num_vfs_argc - 1][i]] = num_vfs[i];
if (nvfs[i] < 0) { if (nvfs[i] < 0) {
dev_err(&pdev->dev, "num_vfs module parameter cannot be negative\n"); dev_err(&pdev->dev, "num_vfs module parameter cannot be negative\n");
return -EINVAL; return -EINVAL;
} }
} }
for (i = 0; i < sizeof(prb_vf)/sizeof(prb_vf[0]); i++) { for (i = 0; i < sizeof(prb_vf)/sizeof(prb_vf[0]) && i < probe_vfs_argc;
prb_vf[i] = i == MLX4_MAX_PORTS ? probe_vf : 0; i++) {
prb_vf[param_map[probe_vfs_argc - 1][i]] = probe_vf[i];
if (prb_vf[i] < 0 || prb_vf[i] > nvfs[i]) { if (prb_vf[i] < 0 || prb_vf[i] > nvfs[i]) {
dev_err(&pdev->dev, "probe_vf module parameter cannot be negative or greater than num_vfs\n"); dev_err(&pdev->dev, "probe_vf module parameter cannot be negative or greater than num_vfs\n");
return -EINVAL; return -EINVAL;
...@@ -2450,6 +2458,19 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data) ...@@ -2450,6 +2458,19 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data)
goto err_close; goto err_close;
} }
if (sriov_initialized) { if (sriov_initialized) {
int ib_ports = 0;
mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
ib_ports++;
if (ib_ports &&
(num_vfs_argc > 1 || probe_vfs_argc > 1)) {
mlx4_err(dev,
"Invalid syntax of num_vfs/probe_vfs "
"with IB port. Single port VFs syntax"
" is only supported when all ports "
"are configured as ethernet\n");
goto err_close;
}
for (i = 0; i < sizeof(nvfs)/sizeof(nvfs[0]); i++) { for (i = 0; i < sizeof(nvfs)/sizeof(nvfs[0]); i++) {
unsigned j; unsigned j;
for (j = 0; j < nvfs[i]; ++sum, ++j) { for (j = 0; j < nvfs[i]; ++sum, ++j) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment