Skip to content

Commit e1ca01a

Browse files
gal-pressmanjgunthorpe
authored andcommitted
RDMA/efa: Report host information to the device
The host info feature allows the driver to infrom the EFA device firmware with system configuration for debugging and troubleshooting purposes. The host info buffer is passed as an admin command DMA mapped control buffer, and is unmapped and freed once the command CQE is consumed. Currently, the setting of host info is done for each device on its probe. Failing to set the host info for the device shall not disturb the probe flow, any errors will be discarded. Link: https://lore.kernel.org/r/20200512152204.93091-3-galpress@amazon.com Reviewed-by: Firas JahJah <firasj@amazon.com> Reviewed-by: Guy Tzalik <gtzalik@amazon.com> Signed-off-by: Gal Pressman <galpress@amazon.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent cc8a635 commit e1ca01a

4 files changed

Lines changed: 130 additions & 10 deletions

File tree

‎drivers/infiniband/hw/efa/efa_admin_cmds_defs.h‎

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ enum efa_admin_aq_feature_id {
3737
EFA_ADMIN_NETWORK_ATTR = 3,
3838
EFA_ADMIN_QUEUE_ATTR = 4,
3939
EFA_ADMIN_HW_HINTS = 5,
40-
EFA_ADMIN_FEATURES_OPCODE_NUM = 8,
40+
EFA_ADMIN_HOST_INFO = 6,
4141
};
4242

4343
/* QP transport type */
@@ -799,6 +799,54 @@ struct efa_admin_mmio_req_read_less_resp {
799799
u32 reg_val;
800800
};
801801

802+
enum efa_admin_os_type {
803+
EFA_ADMIN_OS_LINUX = 0,
804+
};
805+
806+
struct efa_admin_host_info {
807+
/* OS distribution string format */
808+
u8 os_dist_str[128];
809+
810+
/* Defined in enum efa_admin_os_type */
811+
u32 os_type;
812+
813+
/* Kernel version string format */
814+
u8 kernel_ver_str[32];
815+
816+
/* Kernel version numeric format */
817+
u32 kernel_ver;
818+
819+
/*
820+
* 7:0 : driver_module_type
821+
* 15:8 : driver_sub_minor
822+
* 23:16 : driver_minor
823+
* 31:24 : driver_major
824+
*/
825+
u32 driver_ver;
826+
827+
/*
828+
* Device's Bus, Device and Function
829+
* 2:0 : function
830+
* 7:3 : device
831+
* 15:8 : bus
832+
*/
833+
u16 bdf;
834+
835+
/*
836+
* Spec version
837+
* 7:0 : spec_minor
838+
* 15:8 : spec_major
839+
*/
840+
u16 spec_ver;
841+
842+
/*
843+
* 0 : intree - Intree driver
844+
* 1 : gdr - GPUDirect RDMA supported
845+
* 31:2 : reserved2
846+
*/
847+
u32 flags;
848+
};
849+
802850
/* create_qp_cmd */
803851
#define EFA_ADMIN_CREATE_QP_CMD_SQ_VIRT_MASK BIT(0)
804852
#define EFA_ADMIN_CREATE_QP_CMD_RQ_VIRT_MASK BIT(1)
@@ -820,4 +868,17 @@ struct efa_admin_mmio_req_read_less_resp {
820868
/* feature_device_attr_desc */
821869
#define EFA_ADMIN_FEATURE_DEVICE_ATTR_DESC_RDMA_READ_MASK BIT(0)
822870

871+
/* host_info */
872+
#define EFA_ADMIN_HOST_INFO_DRIVER_MODULE_TYPE_MASK GENMASK(7, 0)
873+
#define EFA_ADMIN_HOST_INFO_DRIVER_SUB_MINOR_MASK GENMASK(15, 8)
874+
#define EFA_ADMIN_HOST_INFO_DRIVER_MINOR_MASK GENMASK(23, 16)
875+
#define EFA_ADMIN_HOST_INFO_DRIVER_MAJOR_MASK GENMASK(31, 24)
876+
#define EFA_ADMIN_HOST_INFO_FUNCTION_MASK GENMASK(2, 0)
877+
#define EFA_ADMIN_HOST_INFO_DEVICE_MASK GENMASK(7, 3)
878+
#define EFA_ADMIN_HOST_INFO_BUS_MASK GENMASK(15, 8)
879+
#define EFA_ADMIN_HOST_INFO_SPEC_MINOR_MASK GENMASK(7, 0)
880+
#define EFA_ADMIN_HOST_INFO_SPEC_MAJOR_MASK GENMASK(15, 8)
881+
#define EFA_ADMIN_HOST_INFO_INTREE_MASK BIT(0)
882+
#define EFA_ADMIN_HOST_INFO_GDR_MASK BIT(1)
883+
823884
#endif /* _EFA_ADMIN_CMDS_H_ */

‎drivers/infiniband/hw/efa/efa_com_cmd.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ int efa_com_destroy_ah(struct efa_com_dev *edev,
351351
return 0;
352352
}
353353

354-
static bool
354+
bool
355355
efa_com_check_supported_feature_id(struct efa_com_dev *edev,
356356
enum efa_admin_aq_feature_id feature_id)
357357
{
@@ -517,12 +517,12 @@ int efa_com_get_hw_hints(struct efa_com_dev *edev,
517517
return 0;
518518
}
519519

520-
static int efa_com_set_feature_ex(struct efa_com_dev *edev,
521-
struct efa_admin_set_feature_resp *set_resp,
522-
struct efa_admin_set_feature_cmd *set_cmd,
523-
enum efa_admin_aq_feature_id feature_id,
524-
dma_addr_t control_buf_dma_addr,
525-
u32 control_buff_size)
520+
int efa_com_set_feature_ex(struct efa_com_dev *edev,
521+
struct efa_admin_set_feature_resp *set_resp,
522+
struct efa_admin_set_feature_cmd *set_cmd,
523+
enum efa_admin_aq_feature_id feature_id,
524+
dma_addr_t control_buf_dma_addr,
525+
u32 control_buff_size)
526526
{
527527
struct efa_com_admin_queue *aq;
528528
int err;

‎drivers/infiniband/hw/efa/efa_com_cmd.h‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
22
/*
3-
* Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All rights reserved.
3+
* Copyright 2018-2020 Amazon.com, Inc. or its affiliates. All rights reserved.
44
*/
55

66
#ifndef _EFA_COM_CMD_H_
@@ -270,6 +270,15 @@ int efa_com_get_device_attr(struct efa_com_dev *edev,
270270
struct efa_com_get_device_attr_result *result);
271271
int efa_com_get_hw_hints(struct efa_com_dev *edev,
272272
struct efa_com_get_hw_hints_result *result);
273+
bool
274+
efa_com_check_supported_feature_id(struct efa_com_dev *edev,
275+
enum efa_admin_aq_feature_id feature_id);
276+
int efa_com_set_feature_ex(struct efa_com_dev *edev,
277+
struct efa_admin_set_feature_resp *set_resp,
278+
struct efa_admin_set_feature_cmd *set_cmd,
279+
enum efa_admin_aq_feature_id feature_id,
280+
dma_addr_t control_buf_dma_addr,
281+
u32 control_buff_size);
273282
int efa_com_set_aenq_config(struct efa_com_dev *edev, u32 groups);
274283
int efa_com_alloc_pd(struct efa_com_dev *edev,
275284
struct efa_com_alloc_pd_result *result);

‎drivers/infiniband/hw/efa/efa_main.c‎

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
22
/*
3-
* Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All rights reserved.
3+
* Copyright 2018-2020 Amazon.com, Inc. or its affiliates. All rights reserved.
44
*/
55

66
#include <linux/module.h>
77
#include <linux/pci.h>
8+
#include <linux/utsname.h>
9+
#include <linux/version.h>
810

911
#include <rdma/ib_user_verbs.h>
1012

@@ -187,6 +189,52 @@ static void efa_stats_init(struct efa_dev *dev)
187189
atomic64_set(s, 0);
188190
}
189191

192+
static void efa_set_host_info(struct efa_dev *dev)
193+
{
194+
struct efa_admin_set_feature_resp resp = {};
195+
struct efa_admin_set_feature_cmd cmd = {};
196+
struct efa_admin_host_info *hinf;
197+
u32 bufsz = sizeof(*hinf);
198+
dma_addr_t hinf_dma;
199+
200+
if (!efa_com_check_supported_feature_id(&dev->edev,
201+
EFA_ADMIN_HOST_INFO))
202+
return;
203+
204+
/* Failures in host info set shall not disturb probe */
205+
hinf = dma_alloc_coherent(&dev->pdev->dev, bufsz, &hinf_dma,
206+
GFP_KERNEL);
207+
if (!hinf)
208+
return;
209+
210+
strlcpy(hinf->os_dist_str, utsname()->release,
211+
min(sizeof(hinf->os_dist_str), sizeof(utsname()->release)));
212+
hinf->os_type = EFA_ADMIN_OS_LINUX;
213+
strlcpy(hinf->kernel_ver_str, utsname()->version,
214+
min(sizeof(hinf->kernel_ver_str), sizeof(utsname()->version)));
215+
hinf->kernel_ver = LINUX_VERSION_CODE;
216+
EFA_SET(&hinf->driver_ver, EFA_ADMIN_HOST_INFO_DRIVER_MAJOR, 0);
217+
EFA_SET(&hinf->driver_ver, EFA_ADMIN_HOST_INFO_DRIVER_MINOR, 0);
218+
EFA_SET(&hinf->driver_ver, EFA_ADMIN_HOST_INFO_DRIVER_SUB_MINOR, 0);
219+
EFA_SET(&hinf->driver_ver, EFA_ADMIN_HOST_INFO_DRIVER_MODULE_TYPE, 0);
220+
EFA_SET(&hinf->bdf, EFA_ADMIN_HOST_INFO_BUS, dev->pdev->bus->number);
221+
EFA_SET(&hinf->bdf, EFA_ADMIN_HOST_INFO_DEVICE,
222+
PCI_SLOT(dev->pdev->devfn));
223+
EFA_SET(&hinf->bdf, EFA_ADMIN_HOST_INFO_FUNCTION,
224+
PCI_FUNC(dev->pdev->devfn));
225+
EFA_SET(&hinf->spec_ver, EFA_ADMIN_HOST_INFO_SPEC_MAJOR,
226+
EFA_COMMON_SPEC_VERSION_MAJOR);
227+
EFA_SET(&hinf->spec_ver, EFA_ADMIN_HOST_INFO_SPEC_MINOR,
228+
EFA_COMMON_SPEC_VERSION_MINOR);
229+
EFA_SET(&hinf->flags, EFA_ADMIN_HOST_INFO_INTREE, 1);
230+
EFA_SET(&hinf->flags, EFA_ADMIN_HOST_INFO_GDR, 0);
231+
232+
efa_com_set_feature_ex(&dev->edev, &resp, &cmd, EFA_ADMIN_HOST_INFO,
233+
hinf_dma, bufsz);
234+
235+
dma_free_coherent(&dev->pdev->dev, bufsz, hinf, hinf_dma);
236+
}
237+
190238
static const struct ib_device_ops efa_dev_ops = {
191239
.owner = THIS_MODULE,
192240
.driver_id = RDMA_DRIVER_EFA,
@@ -251,6 +299,8 @@ static int efa_ib_device_add(struct efa_dev *dev)
251299
if (err)
252300
goto err_release_doorbell_bar;
253301

302+
efa_set_host_info(dev);
303+
254304
dev->ibdev.node_type = RDMA_NODE_UNSPECIFIED;
255305
dev->ibdev.phys_port_cnt = 1;
256306
dev->ibdev.num_comp_vectors = 1;

0 commit comments

Comments
 (0)