Try to disable ROCE by sysfs. */
| 641 | |
| 642 | /* Try to disable ROCE by sysfs. */ |
| 643 | static int |
| 644 | mlx5_sys_roce_disable(const char *addr) |
| 645 | { |
| 646 | FILE *file_o; |
| 647 | int enable; |
| 648 | int ret; |
| 649 | |
| 650 | MKSTR(file_p, "/sys/bus/pci/devices/%s/roce_enable", addr); |
| 651 | file_o = fopen(file_p, "rb"); |
| 652 | if (!file_o) { |
| 653 | rte_errno = ENOTSUP; |
| 654 | return -ENOTSUP; |
| 655 | } |
| 656 | ret = fscanf(file_o, "%d", &enable); |
| 657 | if (ret != 1) { |
| 658 | rte_errno = EINVAL; |
| 659 | ret = EINVAL; |
| 660 | goto close; |
| 661 | } else if (!enable) { |
| 662 | ret = 0; |
| 663 | DRV_LOG(INFO, "ROCE has already disabled(sysfs)."); |
| 664 | goto close; |
| 665 | } |
| 666 | fclose(file_o); |
| 667 | file_o = fopen(file_p, "wb"); |
| 668 | if (!file_o) { |
| 669 | rte_errno = ENOTSUP; |
| 670 | return -ENOTSUP; |
| 671 | } |
| 672 | fprintf(file_o, "0\n"); |
| 673 | ret = 0; |
| 674 | close: |
| 675 | if (ret) |
| 676 | DRV_LOG(DEBUG, "Failed to disable ROCE by sysfs: %d.", ret); |
| 677 | else |
| 678 | DRV_LOG(INFO, "ROCE is disabled by sysfs successfully."); |
| 679 | fclose(file_o); |
| 680 | return ret; |
| 681 | } |
| 682 | |
| 683 | static int |
| 684 | mlx5_roce_disable(const struct rte_device *dev) |