MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mlx5_nl_enable_roce_set

Function mlx5_nl_enable_roce_set

dpdk/drivers/common/mlx5/linux/mlx5_nl.c:1823–1867  ·  view source on GitHub ↗

* Set ROCE enable status through Netlink. * * @param[in] nlsk_fd * Netlink socket file descriptor. * @param[in] family_id * the Devlink family ID. * @param pci_addr * The device PCI address. * @param[out] enable * The enable status to set. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */

Source from the content-addressed store, hash-verified

1821 * 0 on success, a negative errno value otherwise and rte_errno is set.
1822 */
1823int
1824mlx5_nl_enable_roce_set(int nlsk_fd, int family_id, const char *pci_addr,
1825 int enable)
1826{
1827 struct nlmsghdr *nlh;
1828 struct genlmsghdr *genl;
1829 uint32_t sn = MLX5_NL_SN_GENERATE;
1830 int ret;
1831 uint8_t buf[NLMSG_ALIGN(sizeof(struct nlmsghdr)) +
1832 NLMSG_ALIGN(sizeof(struct genlmsghdr)) +
1833 NLMSG_ALIGN(sizeof(struct nlattr)) * 6 +
1834 NLMSG_ALIGN(MLX5_NL_MAX_ATTR_SIZE) * 6];
1835 uint8_t cmode = DEVLINK_PARAM_CMODE_DRIVERINIT;
1836 uint8_t ptype = NLA_FLAG;
1837;
1838
1839 memset(buf, 0, sizeof(buf));
1840 nlh = (struct nlmsghdr *)buf;
1841 nlh->nlmsg_len = sizeof(struct nlmsghdr);
1842 nlh->nlmsg_type = family_id;
1843 nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
1844 genl = (struct genlmsghdr *)nl_msg_tail(nlh);
1845 nlh->nlmsg_len += sizeof(struct genlmsghdr);
1846 genl->cmd = DEVLINK_CMD_PARAM_SET;
1847 genl->version = DEVLINK_GENL_VERSION;
1848 nl_attr_put(nlh, DEVLINK_ATTR_BUS_NAME, "pci", 4);
1849 nl_attr_put(nlh, DEVLINK_ATTR_DEV_NAME, pci_addr, strlen(pci_addr) + 1);
1850 nl_attr_put(nlh, DEVLINK_ATTR_PARAM_NAME, "enable_roce", 12);
1851 nl_attr_put(nlh, DEVLINK_ATTR_PARAM_VALUE_CMODE, &cmode, sizeof(cmode));
1852 nl_attr_put(nlh, DEVLINK_ATTR_PARAM_TYPE, &ptype, sizeof(ptype));
1853 if (enable)
1854 nl_attr_put(nlh, DEVLINK_ATTR_PARAM_VALUE_DATA, NULL, 0);
1855 ret = mlx5_nl_send(nlsk_fd, nlh, sn);
1856 if (ret >= 0)
1857 ret = mlx5_nl_recv(nlsk_fd, sn, NULL, NULL);
1858 if (ret < 0) {
1859 DRV_LOG(DEBUG, "Failed to %sable ROCE for device %s by Netlink:"
1860 " %d.", enable ? "en" : "dis", pci_addr, ret);
1861 return ret;
1862 }
1863 DRV_LOG(DEBUG, "Device %s ROCE was %sabled by Netlink successfully.",
1864 pci_addr, enable ? "en" : "dis");
1865 /* Now, need to reload the driver. */
1866 return mlx5_nl_driver_reload(nlsk_fd, family_id, pci_addr);
1867}
1868
1869/**
1870 * Try to parse a Netlink message as a link status update.

Callers 1

mlx5_nl_roce_disableFunction · 0.85

Calls 6

memsetFunction · 0.85
nl_msg_tailFunction · 0.85
nl_attr_putFunction · 0.85
mlx5_nl_sendFunction · 0.85
mlx5_nl_recvFunction · 0.85
mlx5_nl_driver_reloadFunction · 0.85

Tested by

no test coverage detected