git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
doc: add cryptodev sample code
[dpdk.git]
/
lib
/
librte_eal
/
bsdapp
/
eal
/
eal_pci.c
diff --git
a/lib/librte_eal/bsdapp/eal/eal_pci.c
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index
6e289da
..
d3fb3c2
100644
(file)
--- a/
lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/
lib/librte_eal/bsdapp/eal/eal_pci.c
@@
-41,7
+41,6
@@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <stdarg.h>
#include <errno.h>
#include <dirent.h>
#include <limits.h>
#include <errno.h>
#include <dirent.h>
#include <limits.h>
@@
-52,7
+51,6
@@
#include <dev/pci/pcireg.h>
#if defined(RTE_ARCH_X86)
#include <dev/pci/pcireg.h>
#if defined(RTE_ARCH_X86)
-#include <sys/types.h>
#include <machine/cpufunc.h>
#endif
#include <machine/cpufunc.h>
#endif
@@
-91,7
+89,7
@@
extern struct rte_pci_bus rte_pci_bus;
/* Map pci device */
int
/* Map pci device */
int
-rte_
eal_
pci_map_device(struct rte_pci_device *dev)
+rte_pci_map_device(struct rte_pci_device *dev)
{
int ret = -1;
{
int ret = -1;
@@
-113,7
+111,7
@@
rte_eal_pci_map_device(struct rte_pci_device *dev)
/* Unmap pci device */
void
/* Unmap pci device */
void
-rte_
eal_
pci_unmap_device(struct rte_pci_device *dev)
+rte_pci_unmap_device(struct rte_pci_device *dev)
{
/* try unmapping the NIC resources */
switch (dev->kdrv) {
{
/* try unmapping the NIC resources */
switch (dev->kdrv) {
@@
-282,8
+280,7
@@
pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
/* FreeBSD has no NUMA support (yet) */
dev->device.numa_node = 0;
/* FreeBSD has no NUMA support (yet) */
dev->device.numa_node = 0;
- rte_eal_pci_device_name(&dev->addr, dev->name, sizeof(dev->name));
- dev->device.name = dev->name;
+ pci_name_set(dev);
/* FreeBSD has only one pass through driver */
dev->kdrv = RTE_KDRV_NIC_UIO;
/* FreeBSD has only one pass through driver */
dev->kdrv = RTE_KDRV_NIC_UIO;
@@
-319,7
+316,7
@@
pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
/* device is valid, add in list (sorted) */
if (TAILQ_EMPTY(&rte_pci_bus.device_list)) {
/* device is valid, add in list (sorted) */
if (TAILQ_EMPTY(&rte_pci_bus.device_list)) {
- rte_
eal_
pci_add_device(dev);
+ rte_pci_add_device(dev);
}
else {
struct rte_pci_device *dev2 = NULL;
}
else {
struct rte_pci_device *dev2 = NULL;
@@
-330,10
+327,11
@@
pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
if (ret > 0)
continue;
else if (ret < 0) {
if (ret > 0)
continue;
else if (ret < 0) {
- rte_
eal_
pci_insert_device(dev2, dev);
+ rte_pci_insert_device(dev2, dev);
} else { /* already registered */
dev2->kdrv = dev->kdrv;
dev2->max_vfs = dev->max_vfs;
} else { /* already registered */
dev2->kdrv = dev->kdrv;
dev2->max_vfs = dev->max_vfs;
+ pci_name_set(dev2);
memmove(dev2->mem_resource,
dev->mem_resource,
sizeof(dev->mem_resource));
memmove(dev2->mem_resource,
dev->mem_resource,
sizeof(dev->mem_resource));
@@
-341,7
+339,7
@@
pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
}
return 0;
}
}
return 0;
}
- rte_
eal_
pci_add_device(dev);
+ rte_pci_add_device(dev);
}
return 0;
}
return 0;
@@
-356,7
+354,7
@@
skipdev:
* list. Call pci_scan_one() for each pci entry found.
*/
int
* list. Call pci_scan_one() for each pci entry found.
*/
int
-rte_
eal_
pci_scan(void)
+rte_pci_scan(void)
{
int fd;
unsigned dev_count = 0;
{
int fd;
unsigned dev_count = 0;
@@
-455,10
+453,11
@@
error:
}
/* Read PCI config space. */
}
/* Read PCI config space. */
-int rte_
eal_
pci_read_config(const struct rte_pci_device *dev,
-
void *buf, size_t len, off_t offset)
+int rte_pci_read_config(const struct rte_pci_device *dev,
+ void *buf, size_t len, off_t offset)
{
int fd = -1;
{
int fd = -1;
+ int size;
struct pci_io pi = {
.pi_sel = {
.pc_domain = dev->addr.domain,
struct pci_io pi = {
.pi_sel = {
.pc_domain = dev->addr.domain,
@@
-467,25
+466,28
@@
int rte_eal_pci_read_config(const struct rte_pci_device *dev,
.pc_func = dev->addr.function,
},
.pi_reg = offset,
.pc_func = dev->addr.function,
},
.pi_reg = offset,
- .pi_width = len,
};
};
- if (len == 3 || len > sizeof(pi.pi_data)) {
- RTE_LOG(ERR, EAL, "%s(): invalid pci read length\n", __func__);
- goto error;
- }
-
fd = open("/dev/pci", O_RDWR);
if (fd < 0) {
RTE_LOG(ERR, EAL, "%s(): error opening /dev/pci\n", __func__);
goto error;
}
fd = open("/dev/pci", O_RDWR);
if (fd < 0) {
RTE_LOG(ERR, EAL, "%s(): error opening /dev/pci\n", __func__);
goto error;
}
- if (ioctl(fd, PCIOCREAD, &pi) < 0)
- goto error;
+ while (len > 0) {
+ size = (len >= 4) ? 4 : ((len >= 2) ? 2 : 1);
+ pi.pi_width = size;
+
+ if (ioctl(fd, PCIOCREAD, &pi) < 0)
+ goto error;
+ memcpy(buf, &pi.pi_data, size);
+
+ buf = (char *)buf + size;
+ pi.pi_reg += size;
+ len -= size;
+ }
close(fd);
close(fd);
- memcpy(buf, &pi.pi_data, len);
return 0;
error:
return 0;
error:
@@
-495,8
+497,8
@@
int rte_eal_pci_read_config(const struct rte_pci_device *dev,
}
/* Write PCI config space. */
}
/* Write PCI config space. */
-int rte_
eal_
pci_write_config(const struct rte_pci_device *dev,
-
const void *buf, size_t len, off_t offset)
+int rte_pci_write_config(const struct rte_pci_device *dev,
+ const void *buf, size_t len, off_t offset)
{
int fd = -1;
{
int fd = -1;
@@
-538,8
+540,8
@@
int rte_eal_pci_write_config(const struct rte_pci_device *dev,
}
int
}
int
-rte_
eal_
pci_ioport_map(struct rte_pci_device *dev, int bar,
-
struct rte_pci_ioport *p)
+rte_pci_ioport_map(struct rte_pci_device *dev, int bar,
+ struct rte_pci_ioport *p)
{
int ret;
{
int ret;
@@
-566,7
+568,7
@@
rte_eal_pci_ioport_map(struct rte_pci_device *dev, int bar,
static void
pci_uio_ioport_read(struct rte_pci_ioport *p,
static void
pci_uio_ioport_read(struct rte_pci_ioport *p,
-
void *data, size_t len, off_t offset)
+ void *data, size_t len, off_t offset)
{
#if defined(RTE_ARCH_X86)
uint8_t *d;
{
#if defined(RTE_ARCH_X86)
uint8_t *d;
@@
-594,8
+596,8
@@
pci_uio_ioport_read(struct rte_pci_ioport *p,
}
void
}
void
-rte_
eal_
pci_ioport_read(struct rte_pci_ioport *p,
-
void *data, size_t len, off_t offset)
+rte_pci_ioport_read(struct rte_pci_ioport *p,
+ void *data, size_t len, off_t offset)
{
switch (p->dev->kdrv) {
case RTE_KDRV_NIC_UIO:
{
switch (p->dev->kdrv) {
case RTE_KDRV_NIC_UIO:
@@
-608,7
+610,7
@@
rte_eal_pci_ioport_read(struct rte_pci_ioport *p,
static void
pci_uio_ioport_write(struct rte_pci_ioport *p,
static void
pci_uio_ioport_write(struct rte_pci_ioport *p,
-
const void *data, size_t len, off_t offset)
+ const void *data, size_t len, off_t offset)
{
#if defined(RTE_ARCH_X86)
const uint8_t *s;
{
#if defined(RTE_ARCH_X86)
const uint8_t *s;
@@
-618,13
+620,13
@@
pci_uio_ioport_write(struct rte_pci_ioport *p,
for (s = data; len > 0; s += size, reg += size, len -= size) {
if (len >= 4) {
size = 4;
for (s = data; len > 0; s += size, reg += size, len -= size) {
if (len >= 4) {
size = 4;
- outl(
*(const uint32_t *)s, reg
);
+ outl(
reg, *(const uint32_t *)s
);
} else if (len >= 2) {
size = 2;
} else if (len >= 2) {
size = 2;
- outw(
*(const uint16_t *)s, reg
);
+ outw(
reg, *(const uint16_t *)s
);
} else {
size = 1;
} else {
size = 1;
- outb(
*s, reg
);
+ outb(
reg, *s
);
}
}
#else
}
}
#else
@@
-636,8
+638,8
@@
pci_uio_ioport_write(struct rte_pci_ioport *p,
}
void
}
void
-rte_
eal_
pci_ioport_write(struct rte_pci_ioport *p,
-
const void *data, size_t len, off_t offset)
+rte_pci_ioport_write(struct rte_pci_ioport *p,
+ const void *data, size_t len, off_t offset)
{
switch (p->dev->kdrv) {
case RTE_KDRV_NIC_UIO:
{
switch (p->dev->kdrv) {
case RTE_KDRV_NIC_UIO:
@@
-649,7
+651,7
@@
rte_eal_pci_ioport_write(struct rte_pci_ioport *p,
}
int
}
int
-rte_
eal_
pci_ioport_unmap(struct rte_pci_ioport *p)
+rte_pci_ioport_unmap(struct rte_pci_ioport *p)
{
int ret;
{
int ret;