aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/nfp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/nfp')
-rw-r--r--drivers/net/nfp/meson.build16
-rw-r--r--drivers/net/nfp/nfp_net.c33
-rw-r--r--drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h1
-rw-r--r--drivers/net/nfp/nfpcore/nfp_cpp.h6
-rw-r--r--drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c184
-rw-r--r--drivers/net/nfp/nfpcore/nfp_cppcore.c9
6 files changed, 88 insertions, 161 deletions
diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
new file mode 100644
index 00000000..3ba37e27
--- /dev/null
+++ b/drivers/net/nfp/meson.build
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Intel Corporation
+
+sources = files('nfpcore/nfp_cpp_pcie_ops.c',
+ 'nfpcore/nfp_nsp.c',
+ 'nfpcore/nfp_cppcore.c',
+ 'nfpcore/nfp_resource.c',
+ 'nfpcore/nfp_mip.c',
+ 'nfpcore/nfp_nffw.c',
+ 'nfpcore/nfp_rtsym.c',
+ 'nfpcore/nfp_nsp_cmds.c',
+ 'nfpcore/nfp_crc.c',
+ 'nfpcore/nfp_mutex.c',
+ 'nfpcore/nfp_nsp_eth.c',
+ 'nfpcore/nfp_hwinfo.c',
+ 'nfp_net.c')
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index faad1ee9..6e5e305f 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -411,8 +411,10 @@ nfp_net_configure(struct rte_eth_dev *dev)
return -EINVAL;
}
- /* Checking RX offloads */
- if (!(rxmode->offloads & DEV_RX_OFFLOAD_CRC_STRIP))
+ /* KEEP_CRC offload flag is not supported by PMD
+ * can remove the below block when DEV_RX_OFFLOAD_CRC_STRIP removed
+ */
+ if (rte_eth_dev_must_keep_crc(rxmode->offloads))
PMD_INIT_LOG(INFO, "HW does strip CRC. No configurable!");
return 0;
@@ -1166,7 +1168,8 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
DEV_RX_OFFLOAD_UDP_CKSUM |
DEV_RX_OFFLOAD_TCP_CKSUM;
- dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+ dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_JUMBO_FRAME |
+ DEV_RX_OFFLOAD_KEEP_CRC;
if (hw->cap & NFP_NET_CFG_CTRL_TXVLAN)
dev_info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT;
@@ -1436,9 +1439,9 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
/* switch to jumbo mode if needed */
if ((uint32_t)mtu > ETHER_MAX_LEN)
- dev->data->dev_conf.rxmode.jumbo_frame = 1;
+ dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
else
- dev->data->dev_conf.rxmode.jumbo_frame = 0;
+ dev->data->dev_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
/* update max frame size */
dev->data->dev_conf.rxmode.max_rx_pkt_len = (uint32_t)mtu;
@@ -2253,11 +2256,15 @@ nfp_net_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
txq->wr_p = 0;
pkt_size -= dma_size;
- if (!pkt_size)
- /* End of packet */
- txds->offset_eop |= PCIE_DESC_TX_EOP;
+
+ /*
+ * Making the EOP, packets with just one segment
+ * the priority
+ */
+ if (likely(!pkt_size))
+ txds->offset_eop = PCIE_DESC_TX_EOP;
else
- txds->offset_eop &= PCIE_DESC_TX_OFFSET_MASK;
+ txds->offset_eop = 0;
pkt = pkt->next;
/* Referencing next free TX descriptor */
@@ -3126,9 +3133,9 @@ static int nfp_pf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
* use a lock file if UIO is being used.
*/
if (dev->kdrv == RTE_KDRV_VFIO)
- cpp = nfp_cpp_from_device_name(dev->device.name, 0);
+ cpp = nfp_cpp_from_device_name(dev, 0);
else
- cpp = nfp_cpp_from_device_name(dev->device.name, 1);
+ cpp = nfp_cpp_from_device_name(dev, 1);
if (!cpp) {
PMD_DRV_LOG(ERR, "A CPP handle can not be obtained");
@@ -3277,9 +3284,7 @@ RTE_PMD_REGISTER_PCI_TABLE(net_nfp_vf, pci_id_nfp_vf_net_map);
RTE_PMD_REGISTER_KMOD_DEP(net_nfp_pf, "* igb_uio | uio_pci_generic | vfio");
RTE_PMD_REGISTER_KMOD_DEP(net_nfp_vf, "* igb_uio | uio_pci_generic | vfio");
-RTE_INIT(nfp_init_log);
-static void
-nfp_init_log(void)
+RTE_INIT(nfp_init_log)
{
nfp_logtype_init = rte_log_register("pmd.net.nfp.init");
if (nfp_logtype_init >= 0)
diff --git a/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h b/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h
index b8541c59..d46574b1 100644
--- a/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h
+++ b/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h
@@ -13,7 +13,6 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
-#include <sys/cdefs.h>
#include <sys/stat.h>
#include <limits.h>
#include <errno.h>
diff --git a/drivers/net/nfp/nfpcore/nfp_cpp.h b/drivers/net/nfp/nfpcore/nfp_cpp.h
index de2ff84e..1427954c 100644
--- a/drivers/net/nfp/nfpcore/nfp_cpp.h
+++ b/drivers/net/nfp/nfpcore/nfp_cpp.h
@@ -6,6 +6,8 @@
#ifndef __NFP_CPP_H__
#define __NFP_CPP_H__
+#include <rte_ethdev_pci.h>
+
#include "nfp-common/nfp_platform.h"
#include "nfp-common/nfp_resid.h"
@@ -54,7 +56,7 @@ struct nfp_cpp_operations {
size_t area_priv_size;
/* Instance an NFP CPP */
- int (*init)(struct nfp_cpp *cpp, const char *devname);
+ int (*init)(struct nfp_cpp *cpp, struct rte_pci_device *dev);
/*
* Free the bus.
@@ -181,7 +183,7 @@ uint32_t __nfp_cpp_model_autodetect(struct nfp_cpp *cpp);
*
* @return NFP CPP handle, or NULL on failure (and set errno accordingly).
*/
-struct nfp_cpp *nfp_cpp_from_device_name(const char *devname,
+struct nfp_cpp *nfp_cpp_from_device_name(struct rte_pci_device *dev,
int driver_lock_needed);
/*
diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
index 2f5e7f6d..c68d9400 100644
--- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
+++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
@@ -31,6 +31,7 @@
#include <sys/file.h>
#include <sys/stat.h>
+#include <rte_ethdev_pci.h>
#include <rte_string_fns.h>
#include "nfp_cpp.h"
@@ -309,13 +310,8 @@ nfp_enable_bars(struct nfp_pcie_user *nfp)
bar->csr = nfp->cfg +
NFP_PCIE_CFG_BAR_PCIETOCPPEXPBAR(bar->index >> 3,
bar->index & 7);
- bar->iomem =
- (char *)mmap(0, 1 << bar->bitsize, PROT_READ | PROT_WRITE,
- MAP_SHARED, nfp->device,
- bar->index << bar->bitsize);
- if (bar->iomem == MAP_FAILED)
- return (-ENOMEM);
+ bar->iomem = nfp->cfg + (bar->index << bar->bitsize);
}
return 0;
}
@@ -345,7 +341,6 @@ nfp_disable_bars(struct nfp_pcie_user *nfp)
for (x = ARRAY_SIZE(nfp->bar); x > 0; x--) {
bar = &nfp->bar[x - 1];
if (bar->iomem) {
- munmap(bar->iomem, 1 << (nfp->barsz - 3));
bar->iomem = NULL;
bar->lock = 0;
}
@@ -639,61 +634,32 @@ nfp_acquire_process_lock(struct nfp_pcie_user *desc)
}
static int
-nfp6000_set_model(struct nfp_pcie_user *desc, struct nfp_cpp *cpp)
+nfp6000_set_model(struct rte_pci_device *dev, struct nfp_cpp *cpp)
{
- char tmp_str[80];
- uint32_t tmp;
- int fp;
-
- snprintf(tmp_str, sizeof(tmp_str), "%s/%s/config", PCI_DEVICES,
- desc->busdev);
-
- fp = open(tmp_str, O_RDONLY);
- if (!fp)
- return -1;
-
- lseek(fp, 0x2e, SEEK_SET);
+ uint32_t model;
- if (read(fp, &tmp, sizeof(tmp)) != sizeof(tmp)) {
- printf("Error reading config file for model\n");
+ if (rte_pci_read_config(dev, &model, 4, 0x2e) < 0) {
+ printf("nfp set model failed\n");
return -1;
}
- tmp = tmp << 16;
-
- if (close(fp) == -1)
- return -1;
-
- nfp_cpp_model_set(cpp, tmp);
+ model = model << 16;
+ nfp_cpp_model_set(cpp, model);
return 0;
}
static int
-nfp6000_set_interface(struct nfp_pcie_user *desc, struct nfp_cpp *cpp)
+nfp6000_set_interface(struct rte_pci_device *dev, struct nfp_cpp *cpp)
{
- char tmp_str[80];
- uint16_t tmp;
- int fp;
-
- snprintf(tmp_str, sizeof(tmp_str), "%s/%s/config", PCI_DEVICES,
- desc->busdev);
+ uint16_t interface;
- fp = open(tmp_str, O_RDONLY);
- if (!fp)
- return -1;
-
- lseek(fp, 0x154, SEEK_SET);
-
- if (read(fp, &tmp, sizeof(tmp)) != sizeof(tmp)) {
- printf("error reading config file for interface\n");
+ if (rte_pci_read_config(dev, &interface, 2, 0x154) < 0) {
+ printf("nfp set interface failed\n");
return -1;
}
- if (close(fp) == -1)
- return -1;
-
- nfp_cpp_interface_set(cpp, tmp);
+ nfp_cpp_interface_set(cpp, interface);
return 0;
}
@@ -704,7 +670,7 @@ nfp6000_set_interface(struct nfp_pcie_user *desc, struct nfp_cpp *cpp)
#define PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc)
#define PCI_EXT_CAP_ID_DSN 0x03
static int
-nfp_pci_find_next_ext_capability(int fp, int cap)
+nfp_pci_find_next_ext_capability(struct rte_pci_device *dev, int cap)
{
uint32_t header;
int ttl;
@@ -713,9 +679,8 @@ nfp_pci_find_next_ext_capability(int fp, int cap)
/* minimum 8 bytes per capability */
ttl = (PCI_CFG_SPACE_EXP_SIZE - PCI_CFG_SPACE_SIZE) / 8;
- lseek(fp, pos, SEEK_SET);
- if (read(fp, &header, sizeof(header)) != sizeof(header)) {
- printf("error reading config file for serial\n");
+ if (rte_pci_read_config(dev, &header, 4, pos) < 0) {
+ printf("nfp error reading extended capabilities\n");
return -1;
}
@@ -734,9 +699,8 @@ nfp_pci_find_next_ext_capability(int fp, int cap)
if (pos < PCI_CFG_SPACE_SIZE)
break;
- lseek(fp, pos, SEEK_SET);
- if (read(fp, &header, sizeof(header)) != sizeof(header)) {
- printf("error reading config file for serial\n");
+ if (rte_pci_read_config(dev, &header, 4, pos) < 0) {
+ printf("nfp error reading extended capabilities\n");
return -1;
}
}
@@ -745,99 +709,70 @@ nfp_pci_find_next_ext_capability(int fp, int cap)
}
static int
-nfp6000_set_serial(struct nfp_pcie_user *desc, struct nfp_cpp *cpp)
+nfp6000_set_serial(struct rte_pci_device *dev, struct nfp_cpp *cpp)
{
- char tmp_str[80];
uint16_t tmp;
uint8_t serial[6];
int serial_len = 6;
- int fp, pos;
+ int pos;
- snprintf(tmp_str, sizeof(tmp_str), "%s/%s/config", PCI_DEVICES,
- desc->busdev);
-
- fp = open(tmp_str, O_RDONLY);
- if (!fp)
- return -1;
-
- pos = nfp_pci_find_next_ext_capability(fp, PCI_EXT_CAP_ID_DSN);
+ pos = nfp_pci_find_next_ext_capability(dev, PCI_EXT_CAP_ID_DSN);
if (pos <= 0) {
- printf("PCI_EXT_CAP_ID_DSN not found. Using default offset\n");
- lseek(fp, 0x156, SEEK_SET);
+ printf("PCI_EXT_CAP_ID_DSN not found. nfp set serial failed\n");
+ return -1;
} else {
- lseek(fp, pos + 6, SEEK_SET);
+ pos += 6;
}
- if (read(fp, &tmp, sizeof(tmp)) != sizeof(tmp)) {
- printf("error reading config file for serial\n");
+ if (rte_pci_read_config(dev, &tmp, 2, pos) < 0) {
+ printf("nfp set serial failed\n");
return -1;
}
serial[4] = (uint8_t)((tmp >> 8) & 0xff);
serial[5] = (uint8_t)(tmp & 0xff);
- if (read(fp, &tmp, sizeof(tmp)) != sizeof(tmp)) {
- printf("error reading config file for serial\n");
+ pos += 2;
+ if (rte_pci_read_config(dev, &tmp, 2, pos) < 0) {
+ printf("nfp set serial failed\n");
return -1;
}
serial[2] = (uint8_t)((tmp >> 8) & 0xff);
serial[3] = (uint8_t)(tmp & 0xff);
- if (read(fp, &tmp, sizeof(tmp)) != sizeof(tmp)) {
- printf("error reading config file for serial\n");
+ pos += 2;
+ if (rte_pci_read_config(dev, &tmp, 2, pos) < 0) {
+ printf("nfp set serial failed\n");
return -1;
}
serial[0] = (uint8_t)((tmp >> 8) & 0xff);
serial[1] = (uint8_t)(tmp & 0xff);
- if (close(fp) == -1)
- return -1;
-
nfp_cpp_serial_set(cpp, serial, serial_len);
return 0;
}
static int
-nfp6000_set_barsz(struct nfp_pcie_user *desc)
+nfp6000_set_barsz(struct rte_pci_device *dev, struct nfp_pcie_user *desc)
{
- char tmp_str[80];
- unsigned long start, end, flags, tmp;
- int i;
- FILE *fp;
-
- snprintf(tmp_str, sizeof(tmp_str), "%s/%s/resource", PCI_DEVICES,
- desc->busdev);
-
- fp = fopen(tmp_str, "r");
- if (!fp)
- return -1;
+ unsigned long tmp;
+ int i = 0;
- if (fscanf(fp, "0x%lx 0x%lx 0x%lx", &start, &end, &flags) == 0) {
- printf("error reading resource file for bar size\n");
- fclose(fp);
- return -1;
- }
+ tmp = dev->mem_resource[0].len;
- if (fclose(fp) == -1)
- return -1;
-
- tmp = (end - start) + 1;
- i = 0;
while (tmp >>= 1)
i++;
+
desc->barsz = i;
return 0;
}
static int
-nfp6000_init(struct nfp_cpp *cpp, const char *devname)
+nfp6000_init(struct nfp_cpp *cpp, struct rte_pci_device *dev)
{
- char link[120];
- char tmp_str[80];
- ssize_t size;
int ret = 0;
uint32_t model;
struct nfp_pcie_user *desc;
@@ -848,7 +783,7 @@ nfp6000_init(struct nfp_cpp *cpp, const char *devname)
memset(desc->busdev, 0, BUSDEV_SZ);
- strlcpy(desc->busdev, devname, sizeof(desc->busdev));
+ strlcpy(desc->busdev, dev->device.name, sizeof(desc->busdev));
if (cpp->driver_lock_needed) {
ret = nfp_acquire_process_lock(desc);
@@ -856,39 +791,16 @@ nfp6000_init(struct nfp_cpp *cpp, const char *devname)
return -1;
}
- snprintf(tmp_str, sizeof(tmp_str), "%s/%s/driver", PCI_DEVICES,
- desc->busdev);
-
- size = readlink(tmp_str, link, sizeof(link));
-
- if (size == -1)
- tmp_str[0] = '\0';
-
- if (size == sizeof(link))
- tmp_str[0] = '\0';
-
- snprintf(tmp_str, sizeof(tmp_str), "%s/%s/resource0", PCI_DEVICES,
- desc->busdev);
-
- desc->device = open(tmp_str, O_RDWR);
- if (desc->device == -1)
- return -1;
-
- if (nfp6000_set_model(desc, cpp) < 0)
+ if (nfp6000_set_model(dev, cpp) < 0)
return -1;
- if (nfp6000_set_interface(desc, cpp) < 0)
+ if (nfp6000_set_interface(dev, cpp) < 0)
return -1;
- if (nfp6000_set_serial(desc, cpp) < 0)
+ if (nfp6000_set_serial(dev, cpp) < 0)
return -1;
- if (nfp6000_set_barsz(desc) < 0)
+ if (nfp6000_set_barsz(dev, desc) < 0)
return -1;
- desc->cfg = (char *)mmap(0, 1 << (desc->barsz - 3),
- PROT_READ | PROT_WRITE,
- MAP_SHARED, desc->device, 0);
-
- if (desc->cfg == MAP_FAILED)
- return -1;
+ desc->cfg = (char *)dev->mem_resource[0].addr;
nfp_enable_bars(desc);
@@ -904,16 +816,8 @@ static void
nfp6000_free(struct nfp_cpp *cpp)
{
struct nfp_pcie_user *desc = nfp_cpp_priv(cpp);
- int x;
- /* Unmap may cause if there are any pending transaxctions */
nfp_disable_bars(desc);
- munmap(desc->cfg, 1 << (desc->barsz - 3));
-
- for (x = ARRAY_SIZE(desc->bar); x > 0; x--) {
- if (desc->bar[x - 1].iomem)
- munmap(desc->bar[x - 1].iomem, 1 << (desc->barsz - 3));
- }
if (cpp->driver_lock_needed)
close(desc->lock);
close(desc->device);
diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c
index f61143f7..75d3c974 100644
--- a/drivers/net/nfp/nfpcore/nfp_cppcore.c
+++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c
@@ -12,6 +12,7 @@
#include <sys/types.h>
#include <rte_byteorder.h>
+#include <rte_ethdev_pci.h>
#include "nfp_cpp.h"
#include "nfp_target.h"
@@ -542,7 +543,7 @@ nfp_xpb_readl(struct nfp_cpp *cpp, uint32_t xpb_addr, uint32_t *value)
}
static struct nfp_cpp *
-nfp_cpp_alloc(const char *devname, int driver_lock_needed)
+nfp_cpp_alloc(struct rte_pci_device *dev, int driver_lock_needed)
{
const struct nfp_cpp_operations *ops;
struct nfp_cpp *cpp;
@@ -561,7 +562,7 @@ nfp_cpp_alloc(const char *devname, int driver_lock_needed)
cpp->driver_lock_needed = driver_lock_needed;
if (cpp->op->init) {
- err = cpp->op->init(cpp, devname);
+ err = cpp->op->init(cpp, dev);
if (err < 0) {
free(cpp);
return NULL;
@@ -604,9 +605,9 @@ nfp_cpp_free(struct nfp_cpp *cpp)
}
struct nfp_cpp *
-nfp_cpp_from_device_name(const char *devname, int driver_lock_needed)
+nfp_cpp_from_device_name(struct rte_pci_device *dev, int driver_lock_needed)
{
- return nfp_cpp_alloc(devname, driver_lock_needed);
+ return nfp_cpp_alloc(dev, driver_lock_needed);
}
/*