aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatan Barak <matanb@mellanox.com>2014-03-19 12:11:53 -0400
committerDavid S. Miller <davem@davemloft.net>2014-03-20 16:18:30 -0400
commitdd41cc3bb90efd455df514899a5d3cf245182eb1 (patch)
tree046ca207b850a978178bf0d0b6e11ca48c9d63b8
parent449fc48866f7d84b0d9a19201de18a4dd4d3488c (diff)
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: Matan Barak <matanb@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c47
1 files changed, 34 insertions, 13 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 472925428de7..61d7bcff4533 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -77,13 +77,17 @@ MODULE_PARM_DESC(msi_x, "attempt to use MSI-X if nonzero");
77 77
78#endif /* CONFIG_PCI_MSI */ 78#endif /* CONFIG_PCI_MSI */
79 79
80static int num_vfs; 80static uint8_t num_vfs[3] = {0, 0, 0};
81module_param(num_vfs, int, 0444); 81static int num_vfs_argc = 3;
82MODULE_PARM_DESC(num_vfs, "enable #num_vfs functions if num_vfs > 0"); 82module_param_array(num_vfs, byte , &num_vfs_argc, 0444);
83 83MODULE_PARM_DESC(num_vfs, "enable #num_vfs functions if num_vfs > 0\n"
84static int probe_vf; 84 "num_vfs=port1,port2,port1+2");
85module_param(probe_vf, int, 0644); 85
86MODULE_PARM_DESC(probe_vf, "number of vfs to probe by pf driver (num_vfs > 0)"); 86static uint8_t probe_vf[3] = {0, 0, 0};
87static int probe_vfs_argc = 3;
88module_param_array(probe_vf, byte, &probe_vfs_argc, 0444);
89MODULE_PARM_DESC(probe_vf, "number of vfs to probe by pf driver (num_vfs > 0)\n"
90 "probe_vf=port1,port2,port1+2");
87 91
88int mlx4_log_num_mgm_entry_size = MLX4_DEFAULT_MGM_LOG_ENTRY_SIZE; 92int mlx4_log_num_mgm_entry_size = MLX4_DEFAULT_MGM_LOG_ENTRY_SIZE;
89module_param_named(log_num_mgm_entry_size, 93module_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 struct mlx4_dev *dev; 2197 struct mlx4_dev *dev;
2194 int err; 2198 int err;
2195 int port; 2199 int port;
2196 int nvfs[MLX4_MAX_PORTS + 1], prb_vf[MLX4_MAX_PORTS + 1]; 2200 int nvfs[MLX4_MAX_PORTS + 1] = {0, 0, 0};
2201 int prb_vf[MLX4_MAX_PORTS + 1] = {0, 0, 0};
2202 const int param_map[MLX4_MAX_PORTS + 1][MLX4_MAX_PORTS + 1] = {
2203 {2, 0, 0}, {0, 1, 2}, {0, 1, 2} };
2197 unsigned total_vfs = 0; 2204 unsigned total_vfs = 0;
2198 int sriov_initialized = 0; 2205 int sriov_initialized = 0;
2199 unsigned int i; 2206 unsigned int i;
@@ -2211,16 +2218,17 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data)
2211 * per port, we must limit the number of VFs to 63 (since their are 2218 * per port, we must limit the number of VFs to 63 (since their are
2212 * 128 MACs) 2219 * 128 MACs)
2213 */ 2220 */
2214 for (i = 0; i < sizeof(nvfs)/sizeof(nvfs[0]); 2221 for (i = 0; i < sizeof(nvfs)/sizeof(nvfs[0]) && i < num_vfs_argc;
2215 total_vfs += nvfs[i], i++) { 2222 total_vfs += nvfs[param_map[num_vfs_argc - 1][i]], i++) {
2216 nvfs[i] = i == MLX4_MAX_PORTS ? num_vfs : 0; 2223 nvfs[param_map[num_vfs_argc - 1][i]] = num_vfs[i];
2217 if (nvfs[i] < 0) { 2224 if (nvfs[i] < 0) {
2218 dev_err(&pdev->dev, "num_vfs module parameter cannot be negative\n"); 2225 dev_err(&pdev->dev, "num_vfs module parameter cannot be negative\n");
2219 return -EINVAL; 2226 return -EINVAL;
2220 } 2227 }
2221 } 2228 }
2222 for (i = 0; i < sizeof(prb_vf)/sizeof(prb_vf[0]); i++) { 2229 for (i = 0; i < sizeof(prb_vf)/sizeof(prb_vf[0]) && i < probe_vfs_argc;
2223 prb_vf[i] = i == MLX4_MAX_PORTS ? probe_vf : 0; 2230 i++) {
2231 prb_vf[param_map[probe_vfs_argc - 1][i]] = probe_vf[i];
2224 if (prb_vf[i] < 0 || prb_vf[i] > nvfs[i]) { 2232 if (prb_vf[i] < 0 || prb_vf[i] > nvfs[i]) {
2225 dev_err(&pdev->dev, "probe_vf module parameter cannot be negative or greater than num_vfs\n"); 2233 dev_err(&pdev->dev, "probe_vf module parameter cannot be negative or greater than num_vfs\n");
2226 return -EINVAL; 2234 return -EINVAL;
@@ -2450,6 +2458,19 @@ slave_start:
2450 goto err_close; 2458 goto err_close;
2451 } 2459 }
2452 if (sriov_initialized) { 2460 if (sriov_initialized) {
2461 int ib_ports = 0;
2462 mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
2463 ib_ports++;
2464
2465 if (ib_ports &&
2466 (num_vfs_argc > 1 || probe_vfs_argc > 1)) {
2467 mlx4_err(dev,
2468 "Invalid syntax of num_vfs/probe_vfs "
2469 "with IB port. Single port VFs syntax"
2470 " is only supported when all ports "
2471 "are configured as ethernet\n");
2472 goto err_close;
2473 }
2453 for (i = 0; i < sizeof(nvfs)/sizeof(nvfs[0]); i++) { 2474 for (i = 0; i < sizeof(nvfs)/sizeof(nvfs[0]); i++) {
2454 unsigned j; 2475 unsigned j;
2455 for (j = 0; j < nvfs[i]; ++sum, ++j) { 2476 for (j = 0; j < nvfs[i]; ++sum, ++j) {