Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Gal Pressman and committed by
Jason Gunthorpe
e1ca01a9 cc8a635e

+130 -10
+62 -1
drivers/infiniband/hw/efa/efa_admin_cmds_defs.h
··· 37 37 EFA_ADMIN_NETWORK_ATTR = 3, 38 38 EFA_ADMIN_QUEUE_ATTR = 4, 39 39 EFA_ADMIN_HW_HINTS = 5, 40 - EFA_ADMIN_FEATURES_OPCODE_NUM = 8, 40 + EFA_ADMIN_HOST_INFO = 6, 41 41 }; 42 42 43 43 /* QP transport type */ ··· 799 799 u32 reg_val; 800 800 }; 801 801 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 + 802 850 /* create_qp_cmd */ 803 851 #define EFA_ADMIN_CREATE_QP_CMD_SQ_VIRT_MASK BIT(0) 804 852 #define EFA_ADMIN_CREATE_QP_CMD_RQ_VIRT_MASK BIT(1) ··· 867 819 868 820 /* feature_device_attr_desc */ 869 821 #define EFA_ADMIN_FEATURE_DEVICE_ATTR_DESC_RDMA_READ_MASK BIT(0) 822 + 823 + /* host_info */ 824 + #define EFA_ADMIN_HOST_INFO_DRIVER_MODULE_TYPE_MASK GENMASK(7, 0) 825 + #define EFA_ADMIN_HOST_INFO_DRIVER_SUB_MINOR_MASK GENMASK(15, 8) 826 + #define EFA_ADMIN_HOST_INFO_DRIVER_MINOR_MASK GENMASK(23, 16) 827 + #define EFA_ADMIN_HOST_INFO_DRIVER_MAJOR_MASK GENMASK(31, 24) 828 + #define EFA_ADMIN_HOST_INFO_FUNCTION_MASK GENMASK(2, 0) 829 + #define EFA_ADMIN_HOST_INFO_DEVICE_MASK GENMASK(7, 3) 830 + #define EFA_ADMIN_HOST_INFO_BUS_MASK GENMASK(15, 8) 831 + #define EFA_ADMIN_HOST_INFO_SPEC_MINOR_MASK GENMASK(7, 0) 832 + #define EFA_ADMIN_HOST_INFO_SPEC_MAJOR_MASK GENMASK(15, 8) 833 + #define EFA_ADMIN_HOST_INFO_INTREE_MASK BIT(0) 834 + #define EFA_ADMIN_HOST_INFO_GDR_MASK BIT(1) 870 835 871 836 #endif /* _EFA_ADMIN_CMDS_H_ */
+7 -7
drivers/infiniband/hw/efa/efa_com_cmd.c
··· 351 351 return 0; 352 352 } 353 353 354 - static bool 354 + bool 355 355 efa_com_check_supported_feature_id(struct efa_com_dev *edev, 356 356 enum efa_admin_aq_feature_id feature_id) 357 357 { ··· 517 517 return 0; 518 518 } 519 519 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) 526 526 { 527 527 struct efa_com_admin_queue *aq; 528 528 int err;
+10 -1
drivers/infiniband/hw/efa/efa_com_cmd.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */ 2 2 /* 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. 4 4 */ 5 5 6 6 #ifndef _EFA_COM_CMD_H_ ··· 270 270 struct efa_com_get_device_attr_result *result); 271 271 int efa_com_get_hw_hints(struct efa_com_dev *edev, 272 272 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); 273 282 int efa_com_set_aenq_config(struct efa_com_dev *edev, u32 groups); 274 283 int efa_com_alloc_pd(struct efa_com_dev *edev, 275 284 struct efa_com_alloc_pd_result *result);
+51 -1
drivers/infiniband/hw/efa/efa_main.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause 2 2 /* 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. 4 4 */ 5 5 6 6 #include <linux/module.h> 7 7 #include <linux/pci.h> 8 + #include <linux/utsname.h> 9 + #include <linux/version.h> 8 10 9 11 #include <rdma/ib_user_verbs.h> 10 12 ··· 189 187 atomic64_set(s, 0); 190 188 } 191 189 190 + static void efa_set_host_info(struct efa_dev *dev) 191 + { 192 + struct efa_admin_set_feature_resp resp = {}; 193 + struct efa_admin_set_feature_cmd cmd = {}; 194 + struct efa_admin_host_info *hinf; 195 + u32 bufsz = sizeof(*hinf); 196 + dma_addr_t hinf_dma; 197 + 198 + if (!efa_com_check_supported_feature_id(&dev->edev, 199 + EFA_ADMIN_HOST_INFO)) 200 + return; 201 + 202 + /* Failures in host info set shall not disturb probe */ 203 + hinf = dma_alloc_coherent(&dev->pdev->dev, bufsz, &hinf_dma, 204 + GFP_KERNEL); 205 + if (!hinf) 206 + return; 207 + 208 + strlcpy(hinf->os_dist_str, utsname()->release, 209 + min(sizeof(hinf->os_dist_str), sizeof(utsname()->release))); 210 + hinf->os_type = EFA_ADMIN_OS_LINUX; 211 + strlcpy(hinf->kernel_ver_str, utsname()->version, 212 + min(sizeof(hinf->kernel_ver_str), sizeof(utsname()->version))); 213 + hinf->kernel_ver = LINUX_VERSION_CODE; 214 + EFA_SET(&hinf->driver_ver, EFA_ADMIN_HOST_INFO_DRIVER_MAJOR, 0); 215 + EFA_SET(&hinf->driver_ver, EFA_ADMIN_HOST_INFO_DRIVER_MINOR, 0); 216 + EFA_SET(&hinf->driver_ver, EFA_ADMIN_HOST_INFO_DRIVER_SUB_MINOR, 0); 217 + EFA_SET(&hinf->driver_ver, EFA_ADMIN_HOST_INFO_DRIVER_MODULE_TYPE, 0); 218 + EFA_SET(&hinf->bdf, EFA_ADMIN_HOST_INFO_BUS, dev->pdev->bus->number); 219 + EFA_SET(&hinf->bdf, EFA_ADMIN_HOST_INFO_DEVICE, 220 + PCI_SLOT(dev->pdev->devfn)); 221 + EFA_SET(&hinf->bdf, EFA_ADMIN_HOST_INFO_FUNCTION, 222 + PCI_FUNC(dev->pdev->devfn)); 223 + EFA_SET(&hinf->spec_ver, EFA_ADMIN_HOST_INFO_SPEC_MAJOR, 224 + EFA_COMMON_SPEC_VERSION_MAJOR); 225 + EFA_SET(&hinf->spec_ver, EFA_ADMIN_HOST_INFO_SPEC_MINOR, 226 + EFA_COMMON_SPEC_VERSION_MINOR); 227 + EFA_SET(&hinf->flags, EFA_ADMIN_HOST_INFO_INTREE, 1); 228 + EFA_SET(&hinf->flags, EFA_ADMIN_HOST_INFO_GDR, 0); 229 + 230 + efa_com_set_feature_ex(&dev->edev, &resp, &cmd, EFA_ADMIN_HOST_INFO, 231 + hinf_dma, bufsz); 232 + 233 + dma_free_coherent(&dev->pdev->dev, bufsz, hinf, hinf_dma); 234 + } 235 + 192 236 static const struct ib_device_ops efa_dev_ops = { 193 237 .owner = THIS_MODULE, 194 238 .driver_id = RDMA_DRIVER_EFA, ··· 298 250 err = efa_com_set_aenq_config(&dev->edev, EFA_AENQ_ENABLED_GROUPS); 299 251 if (err) 300 252 goto err_release_doorbell_bar; 253 + 254 + efa_set_host_info(dev); 301 255 302 256 dev->ibdev.node_type = RDMA_NODE_UNSPECIFIED; 303 257 dev->ibdev.phys_port_cnt = 1;