Commit 211e6c80 authored by Majd Dibbiny's avatar Majd Dibbiny Committed by David S. Miller

net/mlx5_core: Get vendor-id using the query adapter command

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: default avatarMajd Dibbiny <majd@mellanox.com>
Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 707c4602
...@@ -35,34 +35,63 @@ ...@@ -35,34 +35,63 @@
#include <linux/module.h> #include <linux/module.h>
#include "mlx5_core.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; u32 in[MLX5_ST_SZ_DW(query_adapter_in)];
struct mlx5_cmd_query_adapter_mbox_in 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; int err;
out = kzalloc(sizeof(*out), GFP_KERNEL); out = kzalloc(outlen, GFP_KERNEL);
if (!out) if (!out)
return -ENOMEM; return -ENOMEM;
memset(&in, 0, sizeof(in)); err = mlx5_cmd_query_adapter(dev, out, outlen);
in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_ADAPTER);
err = mlx5_cmd_exec(dev, &in, sizeof(in), out, sizeof(*out));
if (err) if (err)
goto out_out; goto out;
if (out->hdr.status) { memcpy(dev->board_id,
err = mlx5_cmd_status_to_err(&out->hdr); MLX5_ADDR_OF(query_adapter_out, out,
goto 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); 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; return err;
} }
EXPORT_SYMBOL(mlx5_core_query_vendor_id);
int mlx5_query_hca_caps(struct mlx5_core_dev *dev) int mlx5_query_hca_caps(struct mlx5_core_dev *dev)
{ {
......
...@@ -768,9 +768,9 @@ static int mlx5_dev_init(struct mlx5_core_dev *dev, struct pci_dev *pdev) ...@@ -768,9 +768,9 @@ static int mlx5_dev_init(struct mlx5_core_dev *dev, struct pci_dev *pdev)
goto err_stop_poll; goto err_stop_poll;
} }
err = mlx5_cmd_query_adapter(dev); err = mlx5_query_board_id(dev);
if (err) { if (err) {
dev_err(&pdev->dev, "query adapter failed\n"); dev_err(&pdev->dev, "query board id failed\n");
goto err_stop_poll; goto err_stop_poll;
} }
......
...@@ -78,7 +78,7 @@ static inline int mlx5_cmd_exec_check_status(struct mlx5_core_dev *dev, u32 *in, ...@@ -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_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_init_hca(struct mlx5_core_dev *dev);
int mlx5_cmd_teardown_hca(struct mlx5_core_dev *dev); int mlx5_cmd_teardown_hca(struct mlx5_core_dev *dev);
......
...@@ -817,6 +817,7 @@ struct mlx5_interface { ...@@ -817,6 +817,7 @@ struct mlx5_interface {
void *mlx5_get_protocol_dev(struct mlx5_core_dev *mdev, int protocol); void *mlx5_get_protocol_dev(struct mlx5_core_dev *mdev, int protocol);
int mlx5_register_interface(struct mlx5_interface *intf); int mlx5_register_interface(struct mlx5_interface *intf);
void mlx5_unregister_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 { struct mlx5_profile {
u64 mask; u64 mask;
......
...@@ -2470,9 +2470,12 @@ union mlx5_ifc_cong_control_roce_ecn_auto_bits { ...@@ -2470,9 +2470,12 @@ union mlx5_ifc_cong_control_roce_ecn_auto_bits {
}; };
struct mlx5_ifc_query_adapter_param_block_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_vendor_id[0x10];
u8 vsd[208][0x8]; u8 vsd[208][0x8];
......
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