Currently, VFs have 0 in their dev->caps.function field.
This is a valid pci id (usually of the PF).

Pass an invalid pci id to the VF via QUERY_FW, to make sure that
if the value gets accessed in the VF driver, it will not be valid.

Signed-off-by: Jack Morgenstein <ja...@dev.mellanox.co.il>
---
 drivers/net/ethernet/mellanox/mlx4/fw.c |   10 +++++++---
 include/linux/mlx4/device.h             |    2 ++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c 
b/drivers/net/ethernet/mellanox/mlx4/fw.c
index 8320f2a..7c579cf 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -889,11 +889,12 @@ int mlx4_QUERY_FW(struct mlx4_dev *dev)
                ((fw_ver & 0xffff0000ull) >> 16) |
                ((fw_ver & 0x0000ffffull) << 16);
 
+       MLX4_GET(lg, outbox, QUERY_FW_PPF_ID);
+       dev->caps.function = lg;
+
        if (mlx4_is_slave(dev))
                goto out;
 
-       MLX4_GET(lg, outbox, QUERY_FW_PPF_ID);
-       dev->caps.function = lg;
 
        MLX4_GET(cmd_if_rev, outbox, QUERY_FW_CMD_IF_REV_OFFSET);
        if (cmd_if_rev < MLX4_COMMAND_INTERFACE_MIN_REV ||
@@ -974,9 +975,12 @@ int mlx4_QUERY_FW_wrapper(struct mlx4_dev *dev, int slave,
        if (err)
                return err;
 
-       /* for slaves, zero out everything except FW version */
+       /* for slaves, set pci PPF ID to invalid and zero out everything
+        * else except FW version */
        outbuf[0] = outbuf[1] = 0;
        memset(&outbuf[8], 0, QUERY_FW_OUT_SIZE - 8);
+       outbuf[QUERY_FW_PPF_ID] = MLX4_INVALID_SLAVE_ID;
+
        return 0;
 }
 
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 6a8f002..8eadf0f 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -534,6 +534,8 @@ struct mlx4_init_port_param {
                if (((dev)->caps.port_mask[port] == MLX4_PORT_TYPE_IB) || \
                        ((dev)->caps.flags & MLX4_DEV_CAP_FLAG_IBOE))
 
+#define MLX4_INVALID_SLAVE_ID  0xFF
+
 static inline int mlx4_is_master(struct mlx4_dev *dev)
 {
        return dev->flags & MLX4_FLAG_MASTER;
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to