Export FW version for RDMAtool
Subsystems (9)
cover Export FW version for RDMAtool
From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>
hi Doug,
This patch set is based on previously sent RDMA netlink work.
Thanks
Leon Romanovsky (2):
RDMA: Simplify get firmware interface
RDMA/netlink: Export FW version
drivers/infiniband/core/device.c | 4 ++-- drivers/infiniband/core/nldev.c | 8 ++++++++ drivers/infiniband/core/sysfs.c | 4 ++-- drivers/infiniband/hw/cxgb3/iwch_provider.c | 5 ++--- drivers/infiniband/hw/cxgb4/provider.c | 5 ++--- drivers/infiniband/hw/hfi1/verbs.c | 5 ++--- drivers/infiniband/hw/i40iw/i40iw_verbs.c | 5 ++--- drivers/infiniband/hw/mlx4/main.c | 5 ++--- drivers/infiniband/hw/mlx5/main.c | 5 ++--- drivers/infiniband/hw/mthca/mthca_provider.c | 5 ++--- drivers/infiniband/hw/nes/nes_verbs.c | 5 ++--- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 5 ++--- drivers/infiniband/hw/qedr/main.c | 5 ++--- drivers/infiniband/hw/usnic/usnic_ib_main.c | 6 ++---- drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c | 5 ++--- drivers/infiniband/ulp/ipoib/ipoib_ethtool.c | 3 +-- include/rdma/ib_verbs.h | 6 ++++-- include/uapi/rdma/rdma_netlink.h | 4 ++++ 18 files changed, 45 insertions(+), 45 deletions(-)
--
2.13.1
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20170627140650.23510-1-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
PATCH 1/2 RDMA: Simplify get firmware interface
From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>
There is a need to forward FW version to user space application through RDMA netlink. In order to make it safe, there is need to declare nla_policy and limit the size of FW string.
The new define IB_FW_VERSION_NAME_MAX will limit the size of FW version string. That define was chosen to be equal to ETHTOOL_FWVERS_LEN, because many drivers anyway are limited by that value indirectly.
The introduction of this define allows us to remove the string size from get_fw_str function signature.
--- drivers/infiniband/core/device.c | 4 ++-- drivers/infiniband/core/sysfs.c | 4 ++-- drivers/infiniband/hw/cxgb3/iwch_provider.c | 5 ++--- drivers/infiniband/hw/cxgb4/provider.c | 5 ++--- drivers/infiniband/hw/hfi1/verbs.c | 5 ++--- drivers/infiniband/hw/i40iw/i40iw_verbs.c | 5 ++--- drivers/infiniband/hw/mlx4/main.c | 5 ++--- drivers/infiniband/hw/mlx5/main.c | 5 ++--- drivers/infiniband/hw/mthca/mthca_provider.c | 5 ++--- drivers/infiniband/hw/nes/nes_verbs.c | 5 ++--- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 5 ++--- drivers/infiniband/hw/qedr/main.c | 5 ++--- drivers/infiniband/hw/usnic/usnic_ib_main.c | 6 ++---- drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c | 5 ++--- drivers/infiniband/ulp/ipoib/ipoib_ethtool.c | 3 +-- include/rdma/ib_verbs.h | 6 ++++-- 16 files changed, 33 insertions(+), 45 deletions(-)
drivers/infiniband/core/device.c +2 -2
@@ -326,10 +326,10 @@ static int read_port_immutable(struct ib_device *device)return 0 ; } -void ib_get_device_fw_str (struct ib_device *dev,char *str,size_t str_len) +void ib_get_device_fw_str (struct ib_device *dev,char *str) {if (dev->get_dev_fw_str) - dev->get_dev_fw_str (dev, str, str_len); + dev->get_dev_fw_str (dev, str);else str[0 ] ='\0' ; }
drivers/infiniband/core/sysfs.c +2 -2
@@ -1210,8 +1210,8 @@ static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr, { struct ib_device *dev = container_of(device, struct ib_device, dev); -ib_get_device_fw_str (dev, buf,PAGE_SIZE ); -strlcat (buf,"\n" ,PAGE_SIZE ); +ib_get_device_fw_str (dev, buf); +strlcat (buf,"\n" ,IB_FW_VERSION_NAME_MAX );return strlen (buf); }
drivers/infiniband/hw/cxgb3/iwch_provider.c +2 -3
@@ -1337,8 +1337,7 @@ static int iwch_port_immutable(struct ib_device *ibdev, u8 port_num,return 0 ; } -static void get_dev_fw_ver_str (struct ib_device *ibdev,char *str, -size_t str_len) +static void get_dev_fw_ver_str (struct ib_device *ibdev,char *str) {struct iwch_dev *iwch_dev =to_iwch_dev (ibdev);struct ethtool_drvinfo info;
@@ -1346,7 +1345,7 @@ static void get_dev_fw_ver_str(struct ib_device *ibdev, char *str,pr_debug ("%s dev 0x%p\n" , __func__, iwch_dev); lldev->ethtool_ops->get_drvinfo (lldev, &info); -snprintf (str, str_len,"%s" , info.fw_version); +snprintf (str,IB_FW_VERSION_NAME_MAX ,"%s" , info.fw_version); }int iwch_register_device (struct iwch_dev *dev)
drivers/infiniband/hw/cxgb4/provider.c +2 -3
@@ -517,14 +517,13 @@ static int c4iw_port_immutable(struct ib_device *ibdev, u8 port_num,return 0 ; } -static void get_dev_fw_str (struct ib_device *dev,char *str, -size_t str_len) +static void get_dev_fw_str (struct ib_device *dev,char *str) { struct c4iw_dev *c4iw_dev = container_of(dev, struct c4iw_dev, ibdev);pr_debug ("%s dev 0x%p\n" , __func__, dev); - snprintf(str, str_len, "%u.%u.%u.%u", + snprintf(str, IB_FW_VERSION_NAME_MAX, "%u.%u.%u.%u", FW_HDR_FW_VER_MAJOR_G(c4iw_dev->rdev.lldi.fw_vers), FW_HDR_FW_VER_MINOR_G(c4iw_dev->rdev.lldi.fw_vers), FW_HDR_FW_VER_MICRO_G(c4iw_dev->rdev.lldi.fw_vers),
drivers/infiniband/hw/hfi1/verbs.c +2 -3
@@ -1564,14 +1564,13 @@ static void init_ibport(struct hfi1_pportdata *ppd)RCU_INIT_POINTER (ibp->rvp.qp[1 ],NULL ); } -static void hfi1_get_dev_fw_str (struct ib_device *ibdev,char *str, -size_t str_len) +static void hfi1_get_dev_fw_str (struct ib_device *ibdev,char *str) {struct rvt_dev_info *rdi =ib_to_rvt (ibdev);struct hfi1_ibdev *dev =dev_from_rdi (rdi);u32 ver =dd_from_dev (dev)->dc8051_ver; -snprintf (str, str_len,"%u.%u.%u" ,dc8051_ver_maj (ver), +snprintf (str,IB_FW_VERSION_NAME_MAX ,"%u.%u.%u" ,dc8051_ver_maj (ver),dc8051_ver_min (ver),dc8051_ver_patch (ver)); }
drivers/infiniband/hw/i40iw/i40iw_verbs.c +2 -3
@@ -2575,12 +2575,11 @@ static const char * const i40iw_hw_stat_names[] = { "iwRdmaInv" }; -static void i40iw_get_dev_fw_str (struct ib_device *dev,char *str, -size_t str_len) +static void i40iw_get_dev_fw_str (struct ib_device *dev,char *str) {u32 firmware_version =I40IW_FW_VERSION ; -snprintf (str, str_len,"%u.%u" , firmware_version, +snprintf (str,IB_FW_VERSION_NAME_MAX ,"%u.%u" , firmware_version, (firmware_version &0x000000ff )); }
drivers/infiniband/hw/mlx4/main.c +2 -3
@@ -2567,12 +2567,11 @@ static int mlx4_port_immutable(struct ib_device *ibdev, u8 port_num,return 0 ; } -static void get_fw_ver_str (struct ib_device *device,char *str, -size_t str_len) +static void get_fw_ver_str (struct ib_device *device,char *str) {struct mlx4_ib_dev *dev = container_of(device, struct mlx4_ib_dev, ib_dev); -snprintf (str, str_len,"%d.%d.%d" , +snprintf (str,IB_FW_VERSION_NAME_MAX ,"%d.%d.%d" , (int ) (dev->dev->caps.fw_ver >>32 ), (int ) (dev->dev->caps.fw_ver >>16 ) &0xffff , (int ) dev->dev->caps.fw_ver &0xffff );
drivers/infiniband/hw/mlx5/main.c +2 -3
@@ -3181,12 +3181,11 @@ static int mlx5_port_immutable(struct ib_device *ibdev, u8 port_num,return 0 ; } -static void get_dev_fw_str (struct ib_device *ibdev,char *str, -size_t str_len) +static void get_dev_fw_str (struct ib_device *ibdev,char *str) {struct mlx5_ib_dev *dev = container_of(ibdev, struct mlx5_ib_dev, ib_dev); -snprintf (str, str_len,"%d.%d.%04d" ,fw_rev_maj (dev->mdev), +snprintf (str,IB_FW_VERSION_NAME_MAX ,"%d.%d.%04d" ,fw_rev_maj (dev->mdev),fw_rev_min (dev->mdev),fw_rev_sub (dev->mdev)); }
drivers/infiniband/hw/mthca/mthca_provider.c +2 -3
@@ -1178,12 +1178,11 @@ static int mthca_port_immutable(struct ib_device *ibdev, u8 port_num,return 0 ; } -static void get_dev_fw_str (struct ib_device *device,char *str, -size_t str_len) +static void get_dev_fw_str (struct ib_device *device,char *str) {struct mthca_dev *dev = container_of(device, struct mthca_dev, ib_dev); -snprintf (str, str_len,"%d.%d.%d" , +snprintf (str,IB_FW_VERSION_NAME_MAX ,"%d.%d.%d" , (int ) (dev->fw_ver >>32 ), (int ) (dev->fw_ver >>16 ) &0xffff , (int ) dev->fw_ver &0xffff );
drivers/infiniband/hw/nes/nes_verbs.c +2 -3
@@ -3672,15 +3672,14 @@ static int nes_port_immutable(struct ib_device *ibdev, u8 port_num,return 0 ; } -static void get_dev_fw_str (struct ib_device *dev,char *str, -size_t str_len) +static void get_dev_fw_str (struct ib_device *dev,char *str) {struct nes_ib_device *nesibdev = container_of(dev, struct nes_ib_device, ibdev);struct nes_vnic *nesvnic = nesibdev->nesvnic;nes_debug (NES_DBG_INIT ,"\n" ); -snprintf (str, str_len,"%u.%u" , +snprintf (str,IB_FW_VERSION_NAME_MAX ,"%u.%u" , (nesvnic->nesdev->nesadapter->firmware_version >>16 ), (nesvnic->nesdev->nesadapter->firmware_version &0x000000ff )); }
drivers/infiniband/hw/ocrdma/ocrdma_main.c +2 -3
@@ -108,12 +108,11 @@ static int ocrdma_port_immutable(struct ib_device *ibdev, u8 port_num,return 0 ; } -static void get_dev_fw_str (struct ib_device *device,char *str, -size_t str_len) +static void get_dev_fw_str (struct ib_device *device,char *str) {struct ocrdma_dev *dev =get_ocrdma_dev (device); -snprintf (str, str_len,"%s" , &dev->attr.fw_ver[0 ]); +snprintf (str,IB_FW_VERSION_NAME_MAX ,"%s" , &dev->attr.fw_ver[0 ]); }static int ocrdma_register_device (struct ocrdma_dev *dev)
drivers/infiniband/hw/qedr/main.c +2 -3
@@ -69,13 +69,12 @@ static enum rdma_link_layer qedr_link_layer(struct ib_device *device,return IB_LINK_LAYER_ETHERNET ; } -static void qedr_get_dev_fw_str (struct ib_device *ibdev,char *str, -size_t str_len) +static void qedr_get_dev_fw_str (struct ib_device *ibdev,char *str) {struct qedr_dev *qedr =get_qedr_dev (ibdev);u32 fw_ver = (u32 )qedr->attr.fw_ver; -snprintf (str, str_len,"%d. %d. %d. %d" , +snprintf (str,IB_FW_VERSION_NAME_MAX ,"%d. %d. %d. %d" , (fw_ver >>24 ) &0xFF , (fw_ver >>16 ) &0xFF , (fw_ver >>8 ) &0xFF , fw_ver &0xFF ); }
drivers/infiniband/hw/usnic/usnic_ib_main.c +2 -4
@@ -333,9 +333,7 @@ static int usnic_port_immutable(struct ib_device *ibdev, u8 port_num,return 0 ; } -static void usnic_get_dev_fw_str (struct ib_device *device, -char *str, -size_t str_len) +static void usnic_get_dev_fw_str (struct ib_device *device,char *str) {struct usnic_ib_dev *us_ibdev = container_of(device, struct usnic_ib_dev, ib_dev);
@@ -345,7 +343,7 @@ static void usnic_get_dev_fw_str(struct ib_device *device, us_ibdev->netdev->ethtool_ops->get_drvinfo (us_ibdev->netdev, &info);mutex_unlock (&us_ibdev->usdev_lock); -snprintf (str, str_len,"%s" , info.fw_version); +snprintf (str,IB_FW_VERSION_NAME_MAX ,"%s" , info.fw_version); }/* Start of PF discovery section */
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +2 -3
@@ -102,12 +102,11 @@ static struct device_attribute *pvrdma_class_attributes[] = { &dev_attr_board_id }; -static void pvrdma_get_fw_ver_str (struct ib_device *device,char *str, -size_t str_len) +static void pvrdma_get_fw_ver_str (struct ib_device *device,char *str) {struct pvrdma_dev *dev = container_of(device, struct pvrdma_dev, ib_dev); -snprintf (str, str_len,"%d.%d.%d\n" , +snprintf (str,IB_FW_VERSION_NAME_MAX ,"%d.%d.%d\n" , (int ) (dev->dsr->caps.fw_ver >>32 ), (int ) (dev->dsr->caps.fw_ver >>16 ) &0xffff , (int ) dev->dsr->caps.fw_ver &0xffff );
drivers/infiniband/ulp/ipoib/ipoib_ethtool.c +1 -2
@@ -62,8 +62,7 @@ static void ipoib_get_drvinfo(struct net_device *netdev, {struct ipoib_dev_priv *priv =ipoib_priv (netdev); -ib_get_device_fw_str (priv->ca, drvinfo->fw_version, -sizeof (drvinfo->fw_version)); +ib_get_device_fw_str (priv->ca, drvinfo->fw_version);strlcpy (drvinfo->bus_info,dev_name (priv->ca->dev.parent),sizeof (drvinfo->bus_info));
include/rdma/ib_verbs.h +4 -2
@@ -64,6 +64,8 @@#include <linux/cgroup_rdma.h> #include <uapi/rdma/ib_user_verbs.h> +#define IB_FW_VERSION_NAME_MAX ETHTOOL_FWVERS_LEN +extern struct workqueue_struct *ib_wq;extern struct workqueue_struct *ib_comp_wq;
@@ -2246,7 +2248,7 @@ struct ib_device {* in fast paths. */ int (*get_port_immutable)(struct ib_device *,u8 ,struct ib_port_immutable *); -void (*get_dev_fw_str)(struct ib_device *,char *str,size_t str_len); +void (*get_dev_fw_str)(struct ib_device *,char *str); };struct ib_client {
@@ -2282,7 +2284,7 @@ struct ib_client {struct ib_device *ib_alloc_device (size_t size);void ib_dealloc_device (struct ib_device *device); -void ib_get_device_fw_str (struct ib_device *device,char *str,size_t str_len); +void ib_get_device_fw_str (struct ib_device *device,char *str); int ib_register_device(struct ib_device *device, int (*port_callback)(struct ib_device *,
Signature · 6 lines
2.13.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20170627140650.23510-2-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Steve Wise
Reviewed-byRE: [PATCH rdma-next 1/2] RDMA: Simplify get firmware interface
Quoted 11 lines
From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>
There is a need to forward FW version to user space application through RDMA netlink. In order to make it safe, there is need to declare
nla_policyand limit the size of FW string.The new define
IB_FW_VERSION_NAME_MAXwill limit the size of FW version string. That define was chosen to be equal toETHTOOL_FWVERS_LEN, because many drivers anyway are limited by that value indirectly.
Quoted 4 lines
The introduction of this define allows us to remove the string size from
get_fw_strfunction signature.
cxgb* and core parts look good.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/2 RDMA/netlink: Export FW version
In reply to a message not in the archiveFrom: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>
Add FW version to the device properties exported
by RDMA netlink, to be used by RDMAtool.
--- drivers/infiniband/core/nldev.c | 8 ++++++++ include/uapi/rdma/rdma_netlink.h | 4 ++++ 2 files changed, 12 insertions(+)
drivers/infiniband/core/nldev.c +8 -0
@@ -40,10 +40,14 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = { [RDMA_NLDEV_ATTR_DEV_NAME ] = { .type =NLA_NUL_STRING , .len = IB_DEVICE_NAME_MAX - 1}, [RDMA_NLDEV_ATTR_PORT_INDEX] = { .type = NLA_U32 }, + [RDMA_NLDEV_ATTR_FW_VERSION ] = { .type =NLA_NUL_STRING , + .len = IB_FW_VERSION_NAME_MAX - 1}, };static int fill_dev_info (struct sk_buff *msg,struct ib_device *device) { +char fw[IB_FW_VERSION_NAME_MAX ]; +if (nla_put_u32 (msg,RDMA_NLDEV_ATTR_DEV_INDEX , device->index))return -EMSGSIZE ;if (nla_put_string (msg,RDMA_NLDEV_ATTR_DEV_NAME , device->name))
@@ -56,6 +60,10 @@ static int fill_dev_info(struct sk_buff *msg, struct ib_device *device) device->attrs.device_cap_flags, 0))return -EMSGSIZE ; +ib_get_device_fw_str (device, fw); +if (nla_put_string (msg,RDMA_NLDEV_ATTR_FW_VERSION , fw)) +return -EMSGSIZE ; +return 0 ; }
include/uapi/rdma/rdma_netlink.h +4 -0
@@ -262,6 +262,10 @@ enum rdma_nldev_attr {*/ RDMA_NLDEV_ATTR_CAP_FLAGS ,/* u64 */ +/* +* Devices without FW will return empty string terminated by "\0" +*/ +RDMA_NLDEV_ATTR_FW_VERSION ,/* string */ RDMA_NLDEV_ATTR_MAX };#endif /* _UAPI_RDMA_NETLINK_H */
Signature · 6 lines
2.13.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20170627140650.23510-3-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Steve Wise
Reviewed-byRE: [PATCH rdma-next 2/2] RDMA/netlink: Export FW version
Quoted 7 lines
From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>
Add FW version to the device properties exported
by RDMA netlink, to be used by RDMAtool.---
looks fine
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html