net/mlx5_core: Get vendor-id using the query adapter command
authorMajd Dibbiny <majd@mellanox.com>
Thu, 4 Jun 2015 16:30:42 +0000 (19:30 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 4 Jun 2015 23:41:01 +0000 (16:41 -0700)
Add two wrapper functions to the query adapter command:

1. mlx5_query_board_id -- replaces the old mlx5_cmd_query_adapter.

2. mlx5_core_query_vendor_id -- retrieves the vendor_id from the
   query_adapter command.

Signed-off-by: Majd Dibbiny <majd@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/fw.c
drivers/net/ethernet/mellanox/mlx5/core/main.c
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
include/linux/mlx5/driver.h
include/linux/mlx5/mlx5_ifc.h

index 801ccadd709abd2ae84a45ffabeb0f153b97d82a..ba87442ef7767126c4dc7cf89b91546ed6232167 100644 (file)
 #include <linux/module.h>
 #include "mlx5_core.h"
 
-int mlx5_cmd_query_adapter(struct mlx5_core_dev *dev)
+int mlx5_cmd_query_adapter(struct mlx5_core_dev *dev, u32 *out, int outlen)
 {
-       struct mlx5_cmd_query_adapter_mbox_out *out;
-       struct mlx5_cmd_query_adapter_mbox_in in;
+       u32 in[MLX5_ST_SZ_DW(query_adapter_in)];
+
+       memset(in, 0, sizeof(in));
+
+       MLX5_SET(query_adapter_in, in, opcode, MLX5_CMD_OP_QUERY_ADAPTER);
+
+       return mlx5_cmd_exec_check_status(dev, in, sizeof(in), out, outlen);
+}
+
+int mlx5_query_board_id(struct mlx5_core_dev *dev)
+{
+       u32 *out;
+       int outlen = MLX5_ST_SZ_BYTES(query_adapter_out);
        int err;
 
-       out = kzalloc(sizeof(*out), GFP_KERNEL);
+       out = kzalloc(outlen, GFP_KERNEL);
        if (!out)
                return -ENOMEM;
 
-       memset(&in, 0, sizeof(in));
-       in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_ADAPTER);
-       err = mlx5_cmd_exec(dev, &in, sizeof(in), out, sizeof(*out));
+       err = mlx5_cmd_query_adapter(dev, out, outlen);
        if (err)
-               goto out_out;
+               goto out;
 
-       if (out->hdr.status) {
-               err = mlx5_cmd_status_to_err(&out->hdr);
-               goto out_out;
-       }
+       memcpy(dev->board_id,
+              MLX5_ADDR_OF(query_adapter_out, out,
+                           query_adapter_struct.vsd_contd_psid),
+              MLX5_FLD_SZ_BYTES(query_adapter_out,
+                                query_adapter_struct.vsd_contd_psid));
 
-       memcpy(dev->board_id, out->vsd_psid, sizeof(out->vsd_psid));
-
-out_out:
+out:
        kfree(out);
+       return err;
+}
+
+int mlx5_core_query_vendor_id(struct mlx5_core_dev *mdev, u32 *vendor_id)
+{
+       u32 *out;
+       int outlen = MLX5_ST_SZ_BYTES(query_adapter_out);
+       int err;
+
+       out = kzalloc(outlen, GFP_KERNEL);
+       if (!out)
+               return -ENOMEM;
 
+       err = mlx5_cmd_query_adapter(mdev, out, outlen);
+       if (err)
+               goto out;
+
+       *vendor_id = MLX5_GET(query_adapter_out, out,
+                             query_adapter_struct.ieee_vendor_id);
+out:
+       kfree(out);
        return err;
 }
+EXPORT_SYMBOL(mlx5_core_query_vendor_id);
 
 int mlx5_query_hca_caps(struct mlx5_core_dev *dev)
 {
index 58354122dfe4080beb1b93e1e5c0771cfef6ff64..afad529838de748efc9f9253c6fde42abbe954a3 100644 (file)
@@ -768,9 +768,9 @@ static int mlx5_dev_init(struct mlx5_core_dev *dev, struct pci_dev *pdev)
                goto err_stop_poll;
        }
 
-       err = mlx5_cmd_query_adapter(dev);
+       err = mlx5_query_board_id(dev);
        if (err) {
-               dev_err(&pdev->dev, "query adapter failed\n");
+               dev_err(&pdev->dev, "query board id failed\n");
                goto err_stop_poll;
        }
 
index 6983c10472553c35d98c8f5007c35df44c175bff..fc88ecaecb4b4307f2d5c796cc91c548e856f845 100644 (file)
@@ -78,7 +78,7 @@ static inline int mlx5_cmd_exec_check_status(struct mlx5_core_dev *dev, u32 *in,
 }
 
 int mlx5_query_hca_caps(struct mlx5_core_dev *dev);
-int mlx5_cmd_query_adapter(struct mlx5_core_dev *dev);
+int mlx5_query_board_id(struct mlx5_core_dev *dev);
 int mlx5_cmd_init_hca(struct mlx5_core_dev *dev);
 int mlx5_cmd_teardown_hca(struct mlx5_core_dev *dev);
 
index 8ab8b8af5c32b337f86c5896c1e0b95c04626e07..b90fb9336d212025024f754a495fdff2d32ff162 100644 (file)
@@ -817,6 +817,7 @@ struct mlx5_interface {
 void *mlx5_get_protocol_dev(struct mlx5_core_dev *mdev, int protocol);
 int mlx5_register_interface(struct mlx5_interface *intf);
 void mlx5_unregister_interface(struct mlx5_interface *intf);
+int mlx5_core_query_vendor_id(struct mlx5_core_dev *mdev, u32 *vendor_id);
 
 struct mlx5_profile {
        u64     mask;
index f06d054ad021c6ca5003fa7ecca6c777e223ae8e..6d2f6fee041cd4f663fd7d6898b8ed8418a95b73 100644 (file)
@@ -2470,9 +2470,12 @@ union mlx5_ifc_cong_control_roce_ecn_auto_bits {
 };
 
 struct mlx5_ifc_query_adapter_param_block_bits {
-       u8         reserved_0[0xe0];
+       u8         reserved_0[0xc0];
 
-       u8         reserved_1[0x10];
+       u8         reserved_1[0x8];
+       u8         ieee_vendor_id[0x18];
+
+       u8         reserved_2[0x10];
        u8         vsd_vendor_id[0x10];
 
        u8         vsd[208][0x8];