Re: [PATCH iproute2 V3 1/4] rdma: Add basic infrastructure for RDMA tool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tue, Jul 04, 2017 at 09:55:38AM CEST, leon@xxxxxxxxxx wrote:
>From: Leon Romanovsky <leonro@xxxxxxxxxxxx>
>
>RDMA devices are cross-functional devices from one side,
>but very tailored for the specific markets from another.
>
>Such diversity caused to spread of RDMA related configuration
>across various tools, e.g. devlink, ip, ethtool, ib specific and
>vendor specific solutions.
>
>This patch adds ability to fill device and port information
>by reading RDMA netlink.
>
>Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>

[...]

	
>+
>+int rd_dev_init_cb(const struct nlmsghdr *nlh, void *data)
>+{
>+	struct nlattr *tb[RDMA_NLDEV_ATTR_MAX] = {};
>+	struct dev_map *dev_map;
>+	struct rdma *rd = data;
>+	const char *dev_name;
>+
>+	mnl_attr_parse(nlh, 0, rd_attr_cb, tb);
>+	if (!tb[RDMA_NLDEV_ATTR_DEV_NAME] || !tb[RDMA_NLDEV_ATTR_DEV_INDEX])
>+		return MNL_CB_ERROR;
>+	if (!tb[RDMA_NLDEV_ATTR_PORT_INDEX]) {
>+		pr_err("This tool doesn't support switches yet\n");
>+		return MNL_CB_ERROR;
>+	}
>+
>+	dev_name = mnl_attr_get_str(tb[RDMA_NLDEV_ATTR_DEV_NAME]);
>+
>+	dev_map = dev_map_alloc(dev_name);
>+	if (!dev_map)
>+		/* The main function will cleanup the allocations */
>+		return MNL_CB_ERROR;
>+	list_add_tail(&dev_map->list, &rd->dev_map_list);
>+
>+	dev_map->num_ports = mnl_attr_get_u32(tb[RDMA_NLDEV_ATTR_PORT_INDEX]);
>+	dev_map->idx = mnl_attr_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]);
>+
>+	return MNL_CB_OK;
>+}
>+
>+void rdma_free_devmap(struct rdma *rd)
>+{
>+	if(!rd)
>+		return;
>+	dev_map_cleanup(rd);
>+}
>+
>+int rdma_exec_cmd(struct rdma *rd, const struct rdma_cmd *cmds, const char *str)

Sometimes the functions are prefixed "rd_", sometimes "rdma_".
I think it would be nice to unify this with "rd_".


>+{
>+	const struct rdma_cmd *c;
>+
>+	/* First argument in objs table is default variant */
>+	if (rd_no_arg(rd))
>+		return cmds->func(rd);
>+
>+	for (c = cmds + 1; c->cmd; ++c) {
>+		if (rd_argv_match(rd, c->cmd)) {
>+			/* Move to next argument */
>+			rd_arg_inc(rd);
>+			return c->func(rd);
>+		}
>+	}
>+
>+	pr_err("Unknown %s '%s'.\n", str, rd_argv(rd));
>+	return 0;
>+}
>+
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux