mirror of
https://github.com/corundum/corundum.git
synced 2025-02-06 08:38:23 +08:00
Attempt to enable device if not connecting via driver
This commit is contained in:
parent
ba5aa5a82b
commit
e7c0f17c32
@ -34,8 +34,10 @@ either expressed or implied, of The Regents of the University of California.
|
|||||||
#include "mqnic.h"
|
#include "mqnic.h"
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -86,6 +88,31 @@ struct mqnic *mqnic_open(const char *dev_name)
|
|||||||
goto fail_mmap_regs;
|
goto fail_mmap_regs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mqnic_reg_read32(dev->regs, MQNIC_REG_FW_ID) == 0xffffffff)
|
||||||
|
{
|
||||||
|
// if we were given a PCIe resource, then we may need to enable the device
|
||||||
|
char path[PATH_MAX+32];
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
|
strcpy(path, dev_name);
|
||||||
|
ptr = strrchr(path, '/');
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
strcpy(++ptr, "enable");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (access(path, F_OK) != -1)
|
||||||
|
{
|
||||||
|
FILE *fp = fopen(path, "w");
|
||||||
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
|
fputc('1', fp);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mqnic_reg_read32(dev->regs, MQNIC_REG_FW_ID) == 0xffffffff)
|
if (mqnic_reg_read32(dev->regs, MQNIC_REG_FW_ID) == 0xffffffff)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error: device needs to be reset\n");
|
fprintf(stderr, "Error: device needs to be reset\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user