diff options
Diffstat (limited to 'xutils.c')
-rw-r--r-- | xutils.c | 108 |
1 files changed, 0 insertions, 108 deletions
@@ -608,114 +608,6 @@ void device_set_flags(const char *ifname, const short flags) close(sock); } -int device_irq_number(const char *ifname) -{ - /* - * Since fetching IRQ numbers from SIOCGIFMAP is deprecated and not - * supported anymore, we need to grab them from procfs - */ - int irq = 0; - char *buffp; - char buff[512]; - char sysname[512]; - FILE *fp; - - if (!strncmp("lo", ifname, strlen("lo"))) - return 0; - - fp = fopen("/proc/interrupts", "r"); - if (!fp) - panic("Cannot open /proc/interrupts!\n"); - - memset(buff, 0, sizeof(buff)); - while (fgets(buff, sizeof(buff), fp) != NULL) { - buff[sizeof(buff) - 1] = 0; - - if (strstr(buff, ifname) == NULL) - continue; - - buffp = buff; - while (*buffp != ':') - buffp++; - *buffp = 0; - irq = atoi(buff); - - memset(buff, 0, sizeof(buff)); - } - - fclose(fp); - - if (irq != 0) - return irq; - /* - * Try sysfs as fallback. Probably wireless devices will be found - * here. We return silently if it fails ... - */ - slprintf(sysname, sizeof(sysname), "/sys/class/net/%s/device/irq", - ifname); - - fp = fopen(sysname, "r"); - if (!fp) - return -ENOENT; - - memset(buff, 0, sizeof(buff)); - if(fgets(buff, sizeof(buff), fp) != NULL) { - buff[sizeof(buff) - 1] = 0; - irq = atoi(buff); - } - - fclose(fp); - - return irq; -} - -int device_set_irq_affinity_list(int irq, unsigned long from, unsigned long to) -{ - int ret, fd; - char file[256], list[64]; - - slprintf(file, sizeof(file), "/proc/irq/%d/smp_affinity_list", irq); - slprintf(list, sizeof(list), "%lu-%lu\n", from, to); - - fd = open(file, O_WRONLY); - if (fd < 0) - return -ENOENT; - - ret = write(fd, list, strlen(list)); - - close(fd); - return ret; -} - -int device_bind_irq_to_cpu(int irq, int cpu) -{ - int ret; - char buff[256]; - char file[256]; - FILE *fp; - - /* Note: first CPU begins with CPU 0 */ - if (irq < 0 || cpu < 0) - return -EINVAL; - - memset(file, 0, sizeof(file)); - memset(buff, 0, sizeof(buff)); - - /* smp_affinity starts counting with CPU 1, 2, ... */ - cpu = cpu + 1; - sprintf(file, "/proc/irq/%d/smp_affinity", irq); - - fp = fopen(file, "w"); - if (!fp) - return -ENOENT; - - sprintf(buff, "%d", cpu); - ret = fwrite(buff, sizeof(buff), 1, fp); - - fclose(fp); - return (ret > 0 ? 0 : ret); -} - void sock_print_net_stats(int sock) { int ret; |