Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9abb0d1b authored by Leon Romanovsky's avatar Leon Romanovsky
Browse files

RDMA: Simplify get firmware interface



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.

Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
parent ac505253
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -336,10 +336,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';
}
+2 −2
Original line number Diff line number Diff line
@@ -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);
}

+2 −3
Original line number Diff line number Diff line
@@ -1336,8 +1336,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;
@@ -1345,7 +1344,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)
+2 −3
Original line number Diff line number Diff line
@@ -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),
+2 −3
Original line number Diff line number Diff line
@@ -1561,14 +1561,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));
}

Loading