|
|
c7ffa4 |
From 3d61e23ad1f24e53358f445cd55784e8cf2b08e9 Mon Sep 17 00:00:00 2001
|
|
|
c7ffa4 |
From: Alejandro Lucero <alejandro.lucero@netronome.com>
|
|
|
c7ffa4 |
Date: Thu, 5 Apr 2018 15:42:47 +0100
|
|
|
c7ffa4 |
Subject: [PATCH 3/3] net/nfp: remove files
|
|
|
c7ffa4 |
|
|
|
c7ffa4 |
New CPP interface makes NSPU interface obsolete. These files are
|
|
|
c7ffa4 |
not needed anymore.
|
|
|
c7ffa4 |
|
|
|
c7ffa4 |
Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
|
|
|
c7ffa4 |
(cherry picked from commit 70217f1d8dc1f87d0b1d70b08cd3199a46f49a47)
|
|
|
c7ffa4 |
---
|
|
|
c7ffa4 |
drivers/net/nfp/nfp_net_eth.h | 82 ------
|
|
|
c7ffa4 |
drivers/net/nfp/nfp_nfpu.c | 108 -------
|
|
|
c7ffa4 |
drivers/net/nfp/nfp_nfpu.h | 55 ----
|
|
|
c7ffa4 |
drivers/net/nfp/nfp_nspu.c | 642 ------------------------------------------
|
|
|
c7ffa4 |
drivers/net/nfp/nfp_nspu.h | 83 ------
|
|
|
c7ffa4 |
5 files changed, 970 deletions(-)
|
|
|
c7ffa4 |
delete mode 100644 drivers/net/nfp/nfp_net_eth.h
|
|
|
c7ffa4 |
delete mode 100644 drivers/net/nfp/nfp_nfpu.c
|
|
|
c7ffa4 |
delete mode 100644 drivers/net/nfp/nfp_nfpu.h
|
|
|
c7ffa4 |
delete mode 100644 drivers/net/nfp/nfp_nspu.c
|
|
|
c7ffa4 |
delete mode 100644 drivers/net/nfp/nfp_nspu.h
|
|
|
c7ffa4 |
|
|
|
c7ffa4 |
diff --git a/drivers/net/nfp/nfp_net_eth.h b/drivers/net/nfp/nfp_net_eth.h
|
|
|
c7ffa4 |
deleted file mode 100644
|
|
|
c7ffa4 |
index af57f03c5..000000000
|
|
|
c7ffa4 |
--- a/drivers/net/nfp/nfp_net_eth.h
|
|
|
c7ffa4 |
+++ /dev/null
|
|
|
c7ffa4 |
@@ -1,82 +0,0 @@
|
|
|
c7ffa4 |
-/*
|
|
|
c7ffa4 |
- * Copyright (c) 2017 Netronome Systems, Inc.
|
|
|
c7ffa4 |
- * All rights reserved.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * Redistribution and use in source and binary forms, with or without
|
|
|
c7ffa4 |
- * modification, are permitted provided that the following conditions are met:
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * 1. Redistributions of source code must retain the above copyright notice,
|
|
|
c7ffa4 |
- * this list of conditions and the following disclaimer.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * 2. Redistributions in binary form must reproduce the above copyright
|
|
|
c7ffa4 |
- * notice, this list of conditions and the following disclaimer in the
|
|
|
c7ffa4 |
- * documentation and/or other materials provided with the distribution
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * 3. Neither the name of the copyright holder nor the names of its
|
|
|
c7ffa4 |
- * contributors may be used to endorse or promote products derived from this
|
|
|
c7ffa4 |
- * software without specific prior written permission.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
c7ffa4 |
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
c7ffa4 |
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
c7ffa4 |
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
c7ffa4 |
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
c7ffa4 |
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
c7ffa4 |
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
c7ffa4 |
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
c7ffa4 |
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
c7ffa4 |
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
c7ffa4 |
- * POSSIBILITY OF SUCH DAMAGE.
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/*
|
|
|
c7ffa4 |
- * vim:shiftwidth=8:noexpandtab
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * @file dpdk/pmd/nfp_net_eth.h
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * Netronome NFP_NET PDM driver
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-union eth_table_entry {
|
|
|
c7ffa4 |
- struct {
|
|
|
c7ffa4 |
- uint64_t port;
|
|
|
c7ffa4 |
- uint64_t state;
|
|
|
c7ffa4 |
- uint8_t mac_addr[6];
|
|
|
c7ffa4 |
- uint8_t resv[2];
|
|
|
c7ffa4 |
- uint64_t control;
|
|
|
c7ffa4 |
- };
|
|
|
c7ffa4 |
- uint64_t raw[4];
|
|
|
c7ffa4 |
-};
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#ifndef BIT_ULL
|
|
|
c7ffa4 |
-#define BIT_ULL(a) (1ULL << (a))
|
|
|
c7ffa4 |
-#endif
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#define NSP_ETH_NBI_PORT_COUNT 24
|
|
|
c7ffa4 |
-#define NSP_ETH_MAX_COUNT (2 * NSP_ETH_NBI_PORT_COUNT)
|
|
|
c7ffa4 |
-#define NSP_ETH_TABLE_SIZE (NSP_ETH_MAX_COUNT * sizeof(union eth_table_entry))
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#define NSP_ETH_PORT_LANES 0xf
|
|
|
c7ffa4 |
-#define NSP_ETH_PORT_INDEX 0xff00
|
|
|
c7ffa4 |
-#define NSP_ETH_PORT_LABEL 0x3f000000000000
|
|
|
c7ffa4 |
-#define NSP_ETH_PORT_PHYLABEL 0xfc0000000000000
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#define NSP_ETH_PORT_LANES_MASK rte_cpu_to_le_64(NSP_ETH_PORT_LANES)
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#define NSP_ETH_STATE_CONFIGURED BIT_ULL(0)
|
|
|
c7ffa4 |
-#define NSP_ETH_STATE_ENABLED BIT_ULL(1)
|
|
|
c7ffa4 |
-#define NSP_ETH_STATE_TX_ENABLED BIT_ULL(2)
|
|
|
c7ffa4 |
-#define NSP_ETH_STATE_RX_ENABLED BIT_ULL(3)
|
|
|
c7ffa4 |
-#define NSP_ETH_STATE_RATE 0xf00
|
|
|
c7ffa4 |
-#define NSP_ETH_STATE_INTERFACE 0xff000
|
|
|
c7ffa4 |
-#define NSP_ETH_STATE_MEDIA 0x300000
|
|
|
c7ffa4 |
-#define NSP_ETH_STATE_OVRD_CHNG BIT_ULL(22)
|
|
|
c7ffa4 |
-#define NSP_ETH_STATE_ANEG 0x3800000
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#define NSP_ETH_CTRL_CONFIGURED BIT_ULL(0)
|
|
|
c7ffa4 |
-#define NSP_ETH_CTRL_ENABLED BIT_ULL(1)
|
|
|
c7ffa4 |
-#define NSP_ETH_CTRL_TX_ENABLED BIT_ULL(2)
|
|
|
c7ffa4 |
-#define NSP_ETH_CTRL_RX_ENABLED BIT_ULL(3)
|
|
|
c7ffa4 |
-#define NSP_ETH_CTRL_SET_RATE BIT_ULL(4)
|
|
|
c7ffa4 |
-#define NSP_ETH_CTRL_SET_LANES BIT_ULL(5)
|
|
|
c7ffa4 |
-#define NSP_ETH_CTRL_SET_ANEG BIT_ULL(6)
|
|
|
c7ffa4 |
diff --git a/drivers/net/nfp/nfp_nfpu.c b/drivers/net/nfp/nfp_nfpu.c
|
|
|
c7ffa4 |
deleted file mode 100644
|
|
|
c7ffa4 |
index f11afef35..000000000
|
|
|
c7ffa4 |
--- a/drivers/net/nfp/nfp_nfpu.c
|
|
|
c7ffa4 |
+++ /dev/null
|
|
|
c7ffa4 |
@@ -1,108 +0,0 @@
|
|
|
c7ffa4 |
-#include <stdlib.h>
|
|
|
c7ffa4 |
-#include <stdio.h>
|
|
|
c7ffa4 |
-#include <string.h>
|
|
|
c7ffa4 |
-#include <unistd.h>
|
|
|
c7ffa4 |
-#include <errno.h>
|
|
|
c7ffa4 |
-#include <sys/file.h>
|
|
|
c7ffa4 |
-#include <sys/stat.h>
|
|
|
c7ffa4 |
-#include <fcntl.h>
|
|
|
c7ffa4 |
-#include <sys/types.h>
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#include <rte_bus_pci.h>
|
|
|
c7ffa4 |
-#include <rte_malloc.h>
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#include "nfp_nfpu.h"
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/* PF BAR and expansion BAR for the NSP interface */
|
|
|
c7ffa4 |
-#define NFP_CFG_PCIE_BAR 0
|
|
|
c7ffa4 |
-#define NFP_CFG_EXP_BAR 7
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#define NFP_CFG_EXP_BAR_CFG_BASE 0x30000
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/* There could be other NFP userspace tools using the NSP interface.
|
|
|
c7ffa4 |
- * Make sure there is no other process using it and locking the access for
|
|
|
c7ffa4 |
- * avoiding problems.
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
-static int
|
|
|
c7ffa4 |
-nspv_aquire_process_lock(nfpu_desc_t *desc)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- int rc;
|
|
|
c7ffa4 |
- struct flock lock;
|
|
|
c7ffa4 |
- char lockname[30];
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- memset(&lock, 0, sizeof(lock));
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- snprintf(lockname, sizeof(lockname), "/var/lock/nfp%d", desc->nfp);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* Using S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH */
|
|
|
c7ffa4 |
- desc->lock = open(lockname, O_RDWR | O_CREAT, 0666);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (desc->lock < 0)
|
|
|
c7ffa4 |
- return desc->lock;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- lock.l_type = F_WRLCK;
|
|
|
c7ffa4 |
- lock.l_whence = SEEK_SET;
|
|
|
c7ffa4 |
- rc = -1;
|
|
|
c7ffa4 |
- while (rc != 0) {
|
|
|
c7ffa4 |
- rc = fcntl(desc->lock, F_SETLK, &lock);
|
|
|
c7ffa4 |
- if (rc < 0) {
|
|
|
c7ffa4 |
- if ((errno != EAGAIN) && (errno != EACCES)) {
|
|
|
c7ffa4 |
- close(desc->lock);
|
|
|
c7ffa4 |
- return rc;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- return 0;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-int
|
|
|
c7ffa4 |
-nfpu_open(struct rte_pci_device *pci_dev, nfpu_desc_t *desc, int nfp)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- void *cfg_base, *mem_base;
|
|
|
c7ffa4 |
- size_t barsz;
|
|
|
c7ffa4 |
- int ret = 0;
|
|
|
c7ffa4 |
- int i = 0;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- desc->nfp = nfp;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- ret = nspv_aquire_process_lock(desc);
|
|
|
c7ffa4 |
- if (ret)
|
|
|
c7ffa4 |
- return -1;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- barsz = pci_dev->mem_resource[0].len;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* barsz in log2 */
|
|
|
c7ffa4 |
- while (barsz >>= 1)
|
|
|
c7ffa4 |
- i++;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- barsz = i;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* Sanity check: we can assume any bar size less than 1MB an error */
|
|
|
c7ffa4 |
- if (barsz < 20)
|
|
|
c7ffa4 |
- return -1;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* Getting address for NFP expansion BAR registers */
|
|
|
c7ffa4 |
- cfg_base = pci_dev->mem_resource[0].addr;
|
|
|
c7ffa4 |
- cfg_base = (uint8_t *)cfg_base + NFP_CFG_EXP_BAR_CFG_BASE;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* Getting address for NFP NSP interface registers */
|
|
|
c7ffa4 |
- mem_base = pci_dev->mem_resource[0].addr;
|
|
|
c7ffa4 |
- mem_base = (uint8_t *)mem_base + (NFP_CFG_EXP_BAR << (barsz - 3));
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- desc->nspu = rte_malloc("nfp nspu", sizeof(nspu_desc_t), 0);
|
|
|
c7ffa4 |
- nfp_nspu_init(desc->nspu, desc->nfp, NFP_CFG_PCIE_BAR, barsz,
|
|
|
c7ffa4 |
- NFP_CFG_EXP_BAR, cfg_base, mem_base);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- return ret;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-int
|
|
|
c7ffa4 |
-nfpu_close(nfpu_desc_t *desc)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- rte_free(desc->nspu);
|
|
|
c7ffa4 |
- close(desc->lock);
|
|
|
c7ffa4 |
- unlink("/var/lock/nfp0");
|
|
|
c7ffa4 |
- return 0;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
diff --git a/drivers/net/nfp/nfp_nfpu.h b/drivers/net/nfp/nfp_nfpu.h
|
|
|
c7ffa4 |
deleted file mode 100644
|
|
|
c7ffa4 |
index e56fa099d..000000000
|
|
|
c7ffa4 |
--- a/drivers/net/nfp/nfp_nfpu.h
|
|
|
c7ffa4 |
+++ /dev/null
|
|
|
c7ffa4 |
@@ -1,55 +0,0 @@
|
|
|
c7ffa4 |
-/*
|
|
|
c7ffa4 |
- * Copyright (c) 2017 Netronome Systems, Inc.
|
|
|
c7ffa4 |
- * All rights reserved.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * Redistribution and use in source and binary forms, with or without
|
|
|
c7ffa4 |
- * modification, are permitted provided that the following conditions are met:
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * 1. Redistributions of source code must retain the above copyright notice,
|
|
|
c7ffa4 |
- * this list of conditions and the following disclaimer.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * 2. Redistributions in binary form must reproduce the above copyright
|
|
|
c7ffa4 |
- * notice, this list of conditions and the following disclaimer in the
|
|
|
c7ffa4 |
- * documentation and/or other materials provided with the distribution
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * 3. Neither the name of the copyright holder nor the names of its
|
|
|
c7ffa4 |
- * contributors may be used to endorse or promote products derived from this
|
|
|
c7ffa4 |
- * software without specific prior written permission.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
c7ffa4 |
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
c7ffa4 |
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
c7ffa4 |
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
c7ffa4 |
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
c7ffa4 |
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
c7ffa4 |
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
c7ffa4 |
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
c7ffa4 |
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
c7ffa4 |
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
c7ffa4 |
- * POSSIBILITY OF SUCH DAMAGE.
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/*
|
|
|
c7ffa4 |
- * vim:shiftwidth=8:noexpandtab
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * @file dpdk/pmd/nfp_nfpu.h
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * Netronome NFP_NET PDM driver
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/*
|
|
|
c7ffa4 |
- * NFP User interface creates a window for talking with NFP NSP processor
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#include <rte_bus_pci.h>
|
|
|
c7ffa4 |
-#include "nfp_nspu.h"
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-typedef struct {
|
|
|
c7ffa4 |
- int nfp;
|
|
|
c7ffa4 |
- int lock;
|
|
|
c7ffa4 |
- nspu_desc_t *nspu;
|
|
|
c7ffa4 |
-} nfpu_desc_t;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-int nfpu_open(struct rte_pci_device *pci_dev, nfpu_desc_t *desc, int nfp);
|
|
|
c7ffa4 |
-int nfpu_close(nfpu_desc_t *desc);
|
|
|
c7ffa4 |
diff --git a/drivers/net/nfp/nfp_nspu.c b/drivers/net/nfp/nfp_nspu.c
|
|
|
c7ffa4 |
deleted file mode 100644
|
|
|
c7ffa4 |
index f90898321..000000000
|
|
|
c7ffa4 |
--- a/drivers/net/nfp/nfp_nspu.c
|
|
|
c7ffa4 |
+++ /dev/null
|
|
|
c7ffa4 |
@@ -1,642 +0,0 @@
|
|
|
c7ffa4 |
-#include <stdlib.h>
|
|
|
c7ffa4 |
-#include <stdio.h>
|
|
|
c7ffa4 |
-#include <string.h>
|
|
|
c7ffa4 |
-#include <unistd.h>
|
|
|
c7ffa4 |
-#include <sys/types.h>
|
|
|
c7ffa4 |
-#include <sys/file.h>
|
|
|
c7ffa4 |
-#include <sys/stat.h>
|
|
|
c7ffa4 |
-#include <fcntl.h>
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#include <rte_log.h>
|
|
|
c7ffa4 |
-#include <rte_byteorder.h>
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#include "nfp_nfpu.h"
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#define CFG_EXP_BAR_ADDR_SZ 1
|
|
|
c7ffa4 |
-#define CFG_EXP_BAR_MAP_TYPE 1
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#define EXP_BAR_TARGET_SHIFT 23
|
|
|
c7ffa4 |
-#define EXP_BAR_LENGTH_SHIFT 27 /* 0=32, 1=64 bit increment */
|
|
|
c7ffa4 |
-#define EXP_BAR_MAP_TYPE_SHIFT 29 /* Bulk BAR map */
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/* NFP target for NSP access */
|
|
|
c7ffa4 |
-#define NFP_NSP_TARGET 7
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/* Expansion BARs for mapping PF vnic BARs */
|
|
|
c7ffa4 |
-#define NFP_NET_PF_CFG_EXP_BAR 6
|
|
|
c7ffa4 |
-#define NFP_NET_PF_HW_QUEUES_EXP_BAR 5
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/*
|
|
|
c7ffa4 |
- * This is an NFP internal address used for configuring properly an NFP
|
|
|
c7ffa4 |
- * expansion BAR.
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
-#define MEM_CMD_BASE_ADDR 0x8100000000
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/* NSP interface registers */
|
|
|
c7ffa4 |
-#define NSP_BASE (MEM_CMD_BASE_ADDR + 0x22100)
|
|
|
c7ffa4 |
-#define NSP_STATUS 0x00
|
|
|
c7ffa4 |
-#define NSP_COMMAND 0x08
|
|
|
c7ffa4 |
-#define NSP_BUFFER 0x10
|
|
|
c7ffa4 |
-#define NSP_DEFAULT_BUF 0x18
|
|
|
c7ffa4 |
-#define NSP_DEFAULT_BUF_CFG 0x20
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#define NSP_MAGIC 0xab10
|
|
|
c7ffa4 |
-#define NSP_STATUS_MAGIC(x) (((x) >> 48) & 0xffff)
|
|
|
c7ffa4 |
-#define NSP_STATUS_MAJOR(x) (int)(((x) >> 44) & 0xf)
|
|
|
c7ffa4 |
-#define NSP_STATUS_MINOR(x) (int)(((x) >> 32) & 0xfff)
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/* NSP commands */
|
|
|
c7ffa4 |
-#define NSP_CMD_RESET 1
|
|
|
c7ffa4 |
-#define NSP_CMD_FW_LOAD 6
|
|
|
c7ffa4 |
-#define NSP_CMD_READ_ETH_TABLE 7
|
|
|
c7ffa4 |
-#define NSP_CMD_WRITE_ETH_TABLE 8
|
|
|
c7ffa4 |
-#define NSP_CMD_GET_SYMBOL 14
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#define NSP_BUFFER_CFG_SIZE_MASK (0xff)
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#define NSP_REG_ADDR(d, off, reg) ((uint8_t *)(d)->mem_base + (off) + (reg))
|
|
|
c7ffa4 |
-#define NSP_REG_VAL(p) (*(uint64_t *)(p))
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/*
|
|
|
c7ffa4 |
- * An NFP expansion BAR is configured for allowing access to a specific NFP
|
|
|
c7ffa4 |
- * target:
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * IN:
|
|
|
c7ffa4 |
- * desc: struct with basic NSP addresses to work with
|
|
|
c7ffa4 |
- * expbar: NFP PF expansion BAR index to configure
|
|
|
c7ffa4 |
- * tgt: NFP target to configure access
|
|
|
c7ffa4 |
- * addr: NFP target address
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * OUT:
|
|
|
c7ffa4 |
- * pcie_offset: NFP PCI BAR offset to work with
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
-static void
|
|
|
c7ffa4 |
-nfp_nspu_mem_bar_cfg(nspu_desc_t *desc, int expbar, int tgt,
|
|
|
c7ffa4 |
- uint64_t addr, uint64_t *pcie_offset)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- uint64_t x, y, barsz;
|
|
|
c7ffa4 |
- uint32_t *expbar_ptr;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- barsz = desc->barsz;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /*
|
|
|
c7ffa4 |
- * NFP CPP address to configure. This comes from NFP 6000
|
|
|
c7ffa4 |
- * datasheet document based on Bulk mapping.
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
- x = (addr >> (barsz - 3)) << (21 - (40 - (barsz - 3)));
|
|
|
c7ffa4 |
- x |= CFG_EXP_BAR_MAP_TYPE << EXP_BAR_MAP_TYPE_SHIFT;
|
|
|
c7ffa4 |
- x |= CFG_EXP_BAR_ADDR_SZ << EXP_BAR_LENGTH_SHIFT;
|
|
|
c7ffa4 |
- x |= tgt << EXP_BAR_TARGET_SHIFT;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* Getting expansion bar configuration register address */
|
|
|
c7ffa4 |
- expbar_ptr = (uint32_t *)desc->cfg_base;
|
|
|
c7ffa4 |
- /* Each physical PCI BAR has 8 NFP expansion BARs */
|
|
|
c7ffa4 |
- expbar_ptr += (desc->pcie_bar * 8) + expbar;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* Writing to the expansion BAR register */
|
|
|
c7ffa4 |
- *expbar_ptr = (uint32_t)x;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* Getting the pcie offset to work with from userspace */
|
|
|
c7ffa4 |
- y = addr & ((uint64_t)(1 << (barsz - 3)) - 1);
|
|
|
c7ffa4 |
- *pcie_offset = y;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/*
|
|
|
c7ffa4 |
- * Configuring an expansion bar for accessing NSP userspace interface. This
|
|
|
c7ffa4 |
- * function configures always the same expansion bar, which implies access to
|
|
|
c7ffa4 |
- * previously configured NFP target is lost.
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
-static void
|
|
|
c7ffa4 |
-nspu_xlate(nspu_desc_t *desc, uint64_t addr, uint64_t *pcie_offset)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- nfp_nspu_mem_bar_cfg(desc, desc->exp_bar, NFP_NSP_TARGET, addr,
|
|
|
c7ffa4 |
- pcie_offset);
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-int
|
|
|
c7ffa4 |
-nfp_nsp_get_abi_version(nspu_desc_t *desc, int *major, int *minor)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- uint64_t pcie_offset;
|
|
|
c7ffa4 |
- uint64_t nsp_reg;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- nspu_xlate(desc, NSP_BASE, &pcie_offset);
|
|
|
c7ffa4 |
- nsp_reg = NSP_REG_VAL(NSP_REG_ADDR(desc, pcie_offset, NSP_STATUS));
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (NSP_STATUS_MAGIC(nsp_reg) != NSP_MAGIC)
|
|
|
c7ffa4 |
- return -1;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- *major = NSP_STATUS_MAJOR(nsp_reg);
|
|
|
c7ffa4 |
- *minor = NSP_STATUS_MINOR(nsp_reg);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- return 0;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-int
|
|
|
c7ffa4 |
-nfp_nspu_init(nspu_desc_t *desc, int nfp, int pcie_bar, size_t pcie_barsz,
|
|
|
c7ffa4 |
- int exp_bar, void *exp_bar_cfg_base, void *exp_bar_mmap)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- uint64_t offset, buffaddr;
|
|
|
c7ffa4 |
- uint64_t nsp_reg;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- desc->nfp = nfp;
|
|
|
c7ffa4 |
- desc->pcie_bar = pcie_bar;
|
|
|
c7ffa4 |
- desc->exp_bar = exp_bar;
|
|
|
c7ffa4 |
- desc->barsz = pcie_barsz;
|
|
|
c7ffa4 |
- desc->windowsz = 1 << (desc->barsz - 3);
|
|
|
c7ffa4 |
- desc->cfg_base = exp_bar_cfg_base;
|
|
|
c7ffa4 |
- desc->mem_base = exp_bar_mmap;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- nspu_xlate(desc, NSP_BASE, &offset);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /*
|
|
|
c7ffa4 |
- * Other NSPU clients can use other buffers. Let's tell NSPU we use the
|
|
|
c7ffa4 |
- * default buffer.
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
- buffaddr = NSP_REG_VAL(NSP_REG_ADDR(desc, offset, NSP_DEFAULT_BUF));
|
|
|
c7ffa4 |
- NSP_REG_VAL(NSP_REG_ADDR(desc, offset, NSP_BUFFER)) = buffaddr;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* NFP internal addresses are 40 bits. Clean all other bits here */
|
|
|
c7ffa4 |
- buffaddr = buffaddr & (((uint64_t)1 << 40) - 1);
|
|
|
c7ffa4 |
- desc->bufaddr = buffaddr;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* Lets get information about the buffer */
|
|
|
c7ffa4 |
- nsp_reg = NSP_REG_VAL(NSP_REG_ADDR(desc, offset, NSP_DEFAULT_BUF_CFG));
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* Buffer size comes in MBs. Coversion to bytes */
|
|
|
c7ffa4 |
- desc->buf_size = ((size_t)nsp_reg & NSP_BUFFER_CFG_SIZE_MASK) << 20;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- return 0;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#define NSPU_NFP_BUF(addr, base, off) \
|
|
|
c7ffa4 |
- (*(uint64_t *)((uint8_t *)(addr)->mem_base + ((base) | (off))))
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#define NSPU_HOST_BUF(base, off) (*(uint64_t *)((uint8_t *)(base) + (off)))
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-static int
|
|
|
c7ffa4 |
-nspu_buff_write(nspu_desc_t *desc, void *buffer, size_t size)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- uint64_t pcie_offset, pcie_window_base, pcie_window_offset;
|
|
|
c7ffa4 |
- uint64_t windowsz = desc->windowsz;
|
|
|
c7ffa4 |
- uint64_t buffaddr, j, i = 0;
|
|
|
c7ffa4 |
- int ret = 0;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (size > desc->buf_size)
|
|
|
c7ffa4 |
- return -1;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- buffaddr = desc->bufaddr;
|
|
|
c7ffa4 |
- windowsz = desc->windowsz;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- while (i < size) {
|
|
|
c7ffa4 |
- /* Expansion bar reconfiguration per window size */
|
|
|
c7ffa4 |
- nspu_xlate(desc, buffaddr + i, &pcie_offset);
|
|
|
c7ffa4 |
- pcie_window_base = pcie_offset & (~(windowsz - 1));
|
|
|
c7ffa4 |
- pcie_window_offset = pcie_offset & (windowsz - 1);
|
|
|
c7ffa4 |
- for (j = pcie_window_offset; ((j < windowsz) && (i < size));
|
|
|
c7ffa4 |
- j += 8) {
|
|
|
c7ffa4 |
- NSPU_NFP_BUF(desc, pcie_window_base, j) =
|
|
|
c7ffa4 |
- NSPU_HOST_BUF(buffer, i);
|
|
|
c7ffa4 |
- i += 8;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- return ret;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-static int
|
|
|
c7ffa4 |
-nspu_buff_read(nspu_desc_t *desc, void *buffer, size_t size)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- uint64_t pcie_offset, pcie_window_base, pcie_window_offset;
|
|
|
c7ffa4 |
- uint64_t windowsz, i = 0, j;
|
|
|
c7ffa4 |
- uint64_t buffaddr;
|
|
|
c7ffa4 |
- int ret = 0;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (size > desc->buf_size)
|
|
|
c7ffa4 |
- return -1;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- buffaddr = desc->bufaddr;
|
|
|
c7ffa4 |
- windowsz = desc->windowsz;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- while (i < size) {
|
|
|
c7ffa4 |
- /* Expansion bar reconfiguration per window size */
|
|
|
c7ffa4 |
- nspu_xlate(desc, buffaddr + i, &pcie_offset);
|
|
|
c7ffa4 |
- pcie_window_base = pcie_offset & (~(windowsz - 1));
|
|
|
c7ffa4 |
- pcie_window_offset = pcie_offset & (windowsz - 1);
|
|
|
c7ffa4 |
- for (j = pcie_window_offset; ((j < windowsz) && (i < size));
|
|
|
c7ffa4 |
- j += 8) {
|
|
|
c7ffa4 |
- NSPU_HOST_BUF(buffer, i) =
|
|
|
c7ffa4 |
- NSPU_NFP_BUF(desc, pcie_window_base, j);
|
|
|
c7ffa4 |
- i += 8;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- return ret;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-static int
|
|
|
c7ffa4 |
-nspu_command(nspu_desc_t *desc, uint16_t cmd, int read, int write,
|
|
|
c7ffa4 |
- void *buffer, size_t rsize, size_t wsize)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- uint64_t status, cmd_reg;
|
|
|
c7ffa4 |
- uint64_t offset;
|
|
|
c7ffa4 |
- int retry = 0;
|
|
|
c7ffa4 |
- int retries = 120;
|
|
|
c7ffa4 |
- int ret = 0;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* Same expansion BAR is used for different things */
|
|
|
c7ffa4 |
- nspu_xlate(desc, NSP_BASE, &offset);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- status = NSP_REG_VAL(NSP_REG_ADDR(desc, offset, NSP_STATUS));
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- while ((status & 0x1) && (retry < retries)) {
|
|
|
c7ffa4 |
- status = NSP_REG_VAL(NSP_REG_ADDR(desc, offset, NSP_STATUS));
|
|
|
c7ffa4 |
- retry++;
|
|
|
c7ffa4 |
- sleep(1);
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (retry == retries)
|
|
|
c7ffa4 |
- return -1;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (write) {
|
|
|
c7ffa4 |
- ret = nspu_buff_write(desc, buffer, wsize);
|
|
|
c7ffa4 |
- if (ret)
|
|
|
c7ffa4 |
- return ret;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* Expansion BAR changes when writing the buffer */
|
|
|
c7ffa4 |
- nspu_xlate(desc, NSP_BASE, &offset);
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- NSP_REG_VAL(NSP_REG_ADDR(desc, offset, NSP_COMMAND)) =
|
|
|
c7ffa4 |
- (uint64_t)wsize << 32 | (uint64_t)cmd << 16 | 1;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- retry = 0;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- cmd_reg = NSP_REG_VAL(NSP_REG_ADDR(desc, offset, NSP_COMMAND));
|
|
|
c7ffa4 |
- while ((cmd_reg & 0x1) && (retry < retries)) {
|
|
|
c7ffa4 |
- cmd_reg = NSP_REG_VAL(NSP_REG_ADDR(desc, offset, NSP_COMMAND));
|
|
|
c7ffa4 |
- retry++;
|
|
|
c7ffa4 |
- sleep(1);
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
- if (retry == retries)
|
|
|
c7ffa4 |
- return -1;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- retry = 0;
|
|
|
c7ffa4 |
- status = NSP_REG_VAL(NSP_REG_ADDR(desc, offset, NSP_STATUS));
|
|
|
c7ffa4 |
- while ((status & 0x1) && (retry < retries)) {
|
|
|
c7ffa4 |
- status = NSP_REG_VAL(NSP_REG_ADDR(desc, offset, NSP_STATUS));
|
|
|
c7ffa4 |
- retry++;
|
|
|
c7ffa4 |
- sleep(1);
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (retry == retries)
|
|
|
c7ffa4 |
- return -1;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- ret = status & (0xff << 8);
|
|
|
c7ffa4 |
- if (ret)
|
|
|
c7ffa4 |
- return ret;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (read) {
|
|
|
c7ffa4 |
- ret = nspu_buff_read(desc, buffer, rsize);
|
|
|
c7ffa4 |
- if (ret)
|
|
|
c7ffa4 |
- return ret;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- return ret;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-static int
|
|
|
c7ffa4 |
-nfp_fw_reset(nspu_desc_t *nspu_desc)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- int res;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- res = nspu_command(nspu_desc, NSP_CMD_RESET, 0, 0, 0, 0, 0);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (res < 0)
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "fw reset failed: error %d", res);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- return res;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#define DEFAULT_FW_PATH "/lib/firmware/netronome"
|
|
|
c7ffa4 |
-#define DEFAULT_FW_FILENAME "nic_dpdk_default.nffw"
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-static int
|
|
|
c7ffa4 |
-nfp_fw_upload(nspu_desc_t *nspu_desc)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- int fw_f;
|
|
|
c7ffa4 |
- char *fw_buf;
|
|
|
c7ffa4 |
- char filename[100];
|
|
|
c7ffa4 |
- struct stat file_stat;
|
|
|
c7ffa4 |
- off_t fsize, bytes;
|
|
|
c7ffa4 |
- ssize_t size;
|
|
|
c7ffa4 |
- int ret;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- size = nspu_desc->buf_size;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- sprintf(filename, "%s/%s", DEFAULT_FW_PATH, DEFAULT_FW_FILENAME);
|
|
|
c7ffa4 |
- fw_f = open(filename, O_RDONLY);
|
|
|
c7ffa4 |
- if (fw_f < 0) {
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "Firmware file %s/%s not found.",
|
|
|
c7ffa4 |
- DEFAULT_FW_PATH, DEFAULT_FW_FILENAME);
|
|
|
c7ffa4 |
- return -ENOENT;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (fstat(fw_f, &file_stat) < 0) {
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "Firmware file %s/%s size is unknown",
|
|
|
c7ffa4 |
- DEFAULT_FW_PATH, DEFAULT_FW_FILENAME);
|
|
|
c7ffa4 |
- close(fw_f);
|
|
|
c7ffa4 |
- return -ENOENT;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- fsize = file_stat.st_size;
|
|
|
c7ffa4 |
- RTE_LOG(DEBUG, PMD, "Firmware file with size: %" PRIu64 "\n",
|
|
|
c7ffa4 |
- (uint64_t)fsize);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (fsize > (off_t)size) {
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "fw file too big: %" PRIu64
|
|
|
c7ffa4 |
- " bytes (%" PRIu64 " max)",
|
|
|
c7ffa4 |
- (uint64_t)fsize, (uint64_t)size);
|
|
|
c7ffa4 |
- close(fw_f);
|
|
|
c7ffa4 |
- return -EINVAL;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- fw_buf = malloc((size_t)size);
|
|
|
c7ffa4 |
- if (!fw_buf) {
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "malloc failed for fw buffer");
|
|
|
c7ffa4 |
- close(fw_f);
|
|
|
c7ffa4 |
- return -ENOMEM;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
- memset(fw_buf, 0, size);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- bytes = read(fw_f, fw_buf, fsize);
|
|
|
c7ffa4 |
- if (bytes != fsize) {
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "Reading fw to buffer failed.\n"
|
|
|
c7ffa4 |
- "Just %" PRIu64 " of %" PRIu64 " bytes read.",
|
|
|
c7ffa4 |
- (uint64_t)bytes, (uint64_t)fsize);
|
|
|
c7ffa4 |
- free(fw_buf);
|
|
|
c7ffa4 |
- close(fw_f);
|
|
|
c7ffa4 |
- return -EIO;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- ret = nspu_command(nspu_desc, NSP_CMD_FW_LOAD, 0, 1, fw_buf, 0, bytes);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- free(fw_buf);
|
|
|
c7ffa4 |
- close(fw_f);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- return ret;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/* Firmware symbol descriptor size */
|
|
|
c7ffa4 |
-#define NFP_SYM_DESC_LEN 40
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#define SYMBOL_DATA(b, off) (*(int64_t *)((b) + (off)))
|
|
|
c7ffa4 |
-#define SYMBOL_UDATA(b, off) (*(uint64_t *)((b) + (off)))
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/* Firmware symbols contain information about how to access what they
|
|
|
c7ffa4 |
- * represent. It can be as simple as an numeric variable declared at a
|
|
|
c7ffa4 |
- * specific NFP memory, but it can also be more complex structures and
|
|
|
c7ffa4 |
- * related to specific hardware functionalities or components. Target,
|
|
|
c7ffa4 |
- * domain and address allow to create the BAR window for accessing such
|
|
|
c7ffa4 |
- * hw object and size defines the length to map.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * A vNIC is a network interface implemented inside the NFP and using a
|
|
|
c7ffa4 |
- * subset of device PCI BARs. Specific firmware symbols allow to map those
|
|
|
c7ffa4 |
- * vNIC bars by host drivers like the NFP PMD.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * Accessing what the symbol represents implies to map the access through
|
|
|
c7ffa4 |
- * a PCI BAR window. NFP expansion BARs are used in this regard through
|
|
|
c7ffa4 |
- * the NSPU interface.
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
-static int
|
|
|
c7ffa4 |
-nfp_nspu_set_bar_from_symbl(nspu_desc_t *desc, const char *symbl,
|
|
|
c7ffa4 |
- uint32_t expbar, uint64_t *pcie_offset,
|
|
|
c7ffa4 |
- ssize_t *size)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- int64_t type;
|
|
|
c7ffa4 |
- int64_t target;
|
|
|
c7ffa4 |
- int64_t domain;
|
|
|
c7ffa4 |
- uint64_t addr;
|
|
|
c7ffa4 |
- char *sym_buf;
|
|
|
c7ffa4 |
- int ret = 0;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- sym_buf = malloc(desc->buf_size);
|
|
|
c7ffa4 |
- if (!sym_buf)
|
|
|
c7ffa4 |
- return -ENOMEM;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- strncpy(sym_buf, symbl, strlen(symbl));
|
|
|
c7ffa4 |
- ret = nspu_command(desc, NSP_CMD_GET_SYMBOL, 1, 1, sym_buf,
|
|
|
c7ffa4 |
- NFP_SYM_DESC_LEN, strlen(symbl));
|
|
|
c7ffa4 |
- if (ret) {
|
|
|
c7ffa4 |
- RTE_LOG(DEBUG, PMD, "symbol resolution (%s) failed\n", symbl);
|
|
|
c7ffa4 |
- goto clean;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* Reading symbol information */
|
|
|
c7ffa4 |
- type = SYMBOL_DATA(sym_buf, 0);
|
|
|
c7ffa4 |
- target = SYMBOL_DATA(sym_buf, 8);
|
|
|
c7ffa4 |
- domain = SYMBOL_DATA(sym_buf, 16);
|
|
|
c7ffa4 |
- addr = SYMBOL_UDATA(sym_buf, 24);
|
|
|
c7ffa4 |
- *size = (ssize_t)SYMBOL_UDATA(sym_buf, 32);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (type != 1) {
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "wrong symbol type\n");
|
|
|
c7ffa4 |
- ret = -EINVAL;
|
|
|
c7ffa4 |
- goto clean;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
- if (!(target == 7 || target == -7)) {
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "wrong symbol target\n");
|
|
|
c7ffa4 |
- ret = -EINVAL;
|
|
|
c7ffa4 |
- goto clean;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
- if (domain == 8 || domain == 9) {
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "wrong symbol domain\n");
|
|
|
c7ffa4 |
- ret = -EINVAL;
|
|
|
c7ffa4 |
- goto clean;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* Adjusting address based on symbol location */
|
|
|
c7ffa4 |
- if ((domain >= 24) && (domain < 28) && (target == 7)) {
|
|
|
c7ffa4 |
- addr = 1ULL << 37 | addr | ((uint64_t)domain & 0x3) << 35;
|
|
|
c7ffa4 |
- } else {
|
|
|
c7ffa4 |
- addr = 1ULL << 39 | addr | ((uint64_t)domain & 0x3f) << 32;
|
|
|
c7ffa4 |
- if (target == -7)
|
|
|
c7ffa4 |
- target = 7;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* Configuring NFP expansion bar for mapping specific PCI BAR window */
|
|
|
c7ffa4 |
- nfp_nspu_mem_bar_cfg(desc, expbar, target, addr, pcie_offset);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* This is the PCI BAR offset to use by the host */
|
|
|
c7ffa4 |
- *pcie_offset |= ((expbar & 0x7) << (desc->barsz - 3));
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-clean:
|
|
|
c7ffa4 |
- free(sym_buf);
|
|
|
c7ffa4 |
- return ret;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-int
|
|
|
c7ffa4 |
-nfp_nsp_fw_setup(nspu_desc_t *desc, const char *sym, uint64_t *pcie_offset)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- ssize_t bar0_sym_size;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* If the symbol resolution works, it implies a firmware app
|
|
|
c7ffa4 |
- * is already there.
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
- if (!nfp_nspu_set_bar_from_symbl(desc, sym, NFP_NET_PF_CFG_EXP_BAR,
|
|
|
c7ffa4 |
- pcie_offset, &bar0_sym_size))
|
|
|
c7ffa4 |
- return 0;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* No firmware app detected or not the right one */
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "No firmware detected. Resetting NFP...\n");
|
|
|
c7ffa4 |
- if (nfp_fw_reset(desc) < 0) {
|
|
|
c7ffa4 |
- RTE_LOG(ERR, PMD, "nfp fw reset failed\n");
|
|
|
c7ffa4 |
- return -ENODEV;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "Reset done.\n");
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "Uploading firmware...\n");
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (nfp_fw_upload(desc) < 0) {
|
|
|
c7ffa4 |
- RTE_LOG(ERR, PMD, "nfp fw upload failed\n");
|
|
|
c7ffa4 |
- return -ENODEV;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "Done.\n");
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* Now the symbol should be there */
|
|
|
c7ffa4 |
- if (nfp_nspu_set_bar_from_symbl(desc, sym, NFP_NET_PF_CFG_EXP_BAR,
|
|
|
c7ffa4 |
- pcie_offset, &bar0_sym_size)) {
|
|
|
c7ffa4 |
- RTE_LOG(ERR, PMD, "nfp PF BAR symbol resolution failed\n");
|
|
|
c7ffa4 |
- return -ENODEV;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- return 0;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-int
|
|
|
c7ffa4 |
-nfp_nsp_map_ctrl_bar(nspu_desc_t *desc, uint64_t *pcie_offset)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- ssize_t bar0_sym_size;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (nfp_nspu_set_bar_from_symbl(desc, "_pf0_net_bar0",
|
|
|
c7ffa4 |
- NFP_NET_PF_CFG_EXP_BAR,
|
|
|
c7ffa4 |
- pcie_offset, &bar0_sym_size))
|
|
|
c7ffa4 |
- return -ENODEV;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- return 0;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/*
|
|
|
c7ffa4 |
- * This is a hardcoded fixed NFP internal CPP bus address for the hw queues unit
|
|
|
c7ffa4 |
- * inside the PCIE island.
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
-#define NFP_CPP_PCIE_QUEUES ((uint64_t)(1ULL << 39) | 0x80000 | \
|
|
|
c7ffa4 |
- ((uint64_t)0x4 & 0x3f) << 32)
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/* Configure a specific NFP expansion bar for accessing the vNIC rx/tx BARs */
|
|
|
c7ffa4 |
-void
|
|
|
c7ffa4 |
-nfp_nsp_map_queues_bar(nspu_desc_t *desc, uint64_t *pcie_offset)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- nfp_nspu_mem_bar_cfg(desc, NFP_NET_PF_HW_QUEUES_EXP_BAR, 0,
|
|
|
c7ffa4 |
- NFP_CPP_PCIE_QUEUES, pcie_offset);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* This is the pcie offset to use by the host */
|
|
|
c7ffa4 |
- *pcie_offset |= ((NFP_NET_PF_HW_QUEUES_EXP_BAR & 0x7) << (27 - 3));
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-int
|
|
|
c7ffa4 |
-nfp_nsp_eth_config(nspu_desc_t *desc, int port, int up)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- union eth_table_entry *entries, *entry;
|
|
|
c7ffa4 |
- int modified;
|
|
|
c7ffa4 |
- int ret, idx;
|
|
|
c7ffa4 |
- int i;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- idx = port;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "Hw ethernet port %d configure...\n", port);
|
|
|
c7ffa4 |
- rte_spinlock_lock(&desc->nsp_lock);
|
|
|
c7ffa4 |
- entries = malloc(NSP_ETH_TABLE_SIZE);
|
|
|
c7ffa4 |
- if (!entries) {
|
|
|
c7ffa4 |
- rte_spinlock_unlock(&desc->nsp_lock);
|
|
|
c7ffa4 |
- return -ENOMEM;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- ret = nspu_command(desc, NSP_CMD_READ_ETH_TABLE, 1, 0, entries,
|
|
|
c7ffa4 |
- NSP_ETH_TABLE_SIZE, 0);
|
|
|
c7ffa4 |
- if (ret) {
|
|
|
c7ffa4 |
- rte_spinlock_unlock(&desc->nsp_lock);
|
|
|
c7ffa4 |
- free(entries);
|
|
|
c7ffa4 |
- return ret;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- entry = entries;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- for (i = 0; i < NSP_ETH_MAX_COUNT; i++) {
|
|
|
c7ffa4 |
- /* ports in use do not appear sequentially in the table */
|
|
|
c7ffa4 |
- if (!(entry->port & NSP_ETH_PORT_LANES_MASK)) {
|
|
|
c7ffa4 |
- /* entry not in use */
|
|
|
c7ffa4 |
- entry++;
|
|
|
c7ffa4 |
- continue;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
- if (idx == 0)
|
|
|
c7ffa4 |
- break;
|
|
|
c7ffa4 |
- idx--;
|
|
|
c7ffa4 |
- entry++;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (i == NSP_ETH_MAX_COUNT) {
|
|
|
c7ffa4 |
- rte_spinlock_unlock(&desc->nsp_lock);
|
|
|
c7ffa4 |
- free(entries);
|
|
|
c7ffa4 |
- return -EINVAL;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (up && !(entry->state & NSP_ETH_STATE_CONFIGURED)) {
|
|
|
c7ffa4 |
- entry->control |= NSP_ETH_STATE_CONFIGURED;
|
|
|
c7ffa4 |
- modified = 1;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (!up && (entry->state & NSP_ETH_STATE_CONFIGURED)) {
|
|
|
c7ffa4 |
- entry->control &= ~NSP_ETH_STATE_CONFIGURED;
|
|
|
c7ffa4 |
- modified = 1;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (modified) {
|
|
|
c7ffa4 |
- ret = nspu_command(desc, NSP_CMD_WRITE_ETH_TABLE, 0, 1, entries,
|
|
|
c7ffa4 |
- 0, NSP_ETH_TABLE_SIZE);
|
|
|
c7ffa4 |
- if (!ret)
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD,
|
|
|
c7ffa4 |
- "Hw ethernet port %d configure done\n", port);
|
|
|
c7ffa4 |
- else
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD,
|
|
|
c7ffa4 |
- "Hw ethernet port %d configure failed\n", port);
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
- rte_spinlock_unlock(&desc->nsp_lock);
|
|
|
c7ffa4 |
- free(entries);
|
|
|
c7ffa4 |
- return ret;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-int
|
|
|
c7ffa4 |
-nfp_nsp_eth_read_table(nspu_desc_t *desc, union eth_table_entry **table)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- int ret;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (!table)
|
|
|
c7ffa4 |
- return -EINVAL;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "Reading hw ethernet table...\n");
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- /* port 0 allocates the eth table and read it using NSPU */
|
|
|
c7ffa4 |
- *table = malloc(NSP_ETH_TABLE_SIZE);
|
|
|
c7ffa4 |
- if (!*table)
|
|
|
c7ffa4 |
- return -ENOMEM;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- ret = nspu_command(desc, NSP_CMD_READ_ETH_TABLE, 1, 0, *table,
|
|
|
c7ffa4 |
- NSP_ETH_TABLE_SIZE, 0);
|
|
|
c7ffa4 |
- if (ret)
|
|
|
c7ffa4 |
- return ret;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- RTE_LOG(INFO, PMD, "Done\n");
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- return 0;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
diff --git a/drivers/net/nfp/nfp_nspu.h b/drivers/net/nfp/nfp_nspu.h
|
|
|
c7ffa4 |
deleted file mode 100644
|
|
|
c7ffa4 |
index 8c33835e5..000000000
|
|
|
c7ffa4 |
--- a/drivers/net/nfp/nfp_nspu.h
|
|
|
c7ffa4 |
+++ /dev/null
|
|
|
c7ffa4 |
@@ -1,83 +0,0 @@
|
|
|
c7ffa4 |
-/*
|
|
|
c7ffa4 |
- * Copyright (c) 2017 Netronome Systems, Inc.
|
|
|
c7ffa4 |
- * All rights reserved.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * Redistribution and use in source and binary forms, with or without
|
|
|
c7ffa4 |
- * modification, are permitted provided that the following conditions are met:
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * 1. Redistributions of source code must retain the above copyright notice,
|
|
|
c7ffa4 |
- * this list of conditions and the following disclaimer.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * 2. Redistributions in binary form must reproduce the above copyright
|
|
|
c7ffa4 |
- * notice, this list of conditions and the following disclaimer in the
|
|
|
c7ffa4 |
- * documentation and/or other materials provided with the distribution
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * 3. Neither the name of the copyright holder nor the names of its
|
|
|
c7ffa4 |
- * contributors may be used to endorse or promote products derived from this
|
|
|
c7ffa4 |
- * software without specific prior written permission.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
c7ffa4 |
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
c7ffa4 |
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
c7ffa4 |
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
c7ffa4 |
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
c7ffa4 |
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
c7ffa4 |
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
c7ffa4 |
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
c7ffa4 |
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
c7ffa4 |
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
c7ffa4 |
- * POSSIBILITY OF SUCH DAMAGE.
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/*
|
|
|
c7ffa4 |
- * vim:shiftwidth=8:noexpandtab
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * @file dpdk/pmd/nfp_nspu.h
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * Netronome NFP_NET PDM driver
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/*
|
|
|
c7ffa4 |
- * NSP is the NFP Service Processor. NSPU is NSP Userspace interface.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * NFP NSP helps with firmware/hardware configuration. NSP is another component
|
|
|
c7ffa4 |
- * in NFP programmable processor and accessing it from host requires to firstly
|
|
|
c7ffa4 |
- * configure a specific NFP PCI expansion BAR.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * Once access is ready, configuration can be done reading and writing
|
|
|
c7ffa4 |
- * from/to a specific PF PCI BAR window. This same interface will allow to
|
|
|
c7ffa4 |
- * create other PCI BAR windows for accessing other NFP components.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * This file includes low-level functions, using the NSPU interface, and high
|
|
|
c7ffa4 |
- * level functions, invoked by the PMD for using NSP services. This allows
|
|
|
c7ffa4 |
- * firmware upload, vNIC PCI BARs mapping and other low-level configurations
|
|
|
c7ffa4 |
- * like link setup.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * NSP access is done during initialization and it is not involved at all with
|
|
|
c7ffa4 |
- * the fast path.
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#include <rte_spinlock.h>
|
|
|
c7ffa4 |
-#include "nfp_net_eth.h"
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-typedef struct {
|
|
|
c7ffa4 |
- int nfp; /* NFP device */
|
|
|
c7ffa4 |
- int pcie_bar; /* PF PCI BAR to work with */
|
|
|
c7ffa4 |
- int exp_bar; /* Expansion BAR number used by NSPU */
|
|
|
c7ffa4 |
- int barsz; /* PCIE BAR log2 size */
|
|
|
c7ffa4 |
- uint64_t bufaddr; /* commands buffer address */
|
|
|
c7ffa4 |
- size_t buf_size; /* commands buffer size */
|
|
|
c7ffa4 |
- uint64_t windowsz; /* NSPU BAR window size */
|
|
|
c7ffa4 |
- void *cfg_base; /* Expansion BARs address */
|
|
|
c7ffa4 |
- void *mem_base; /* NSP interface */
|
|
|
c7ffa4 |
- rte_spinlock_t nsp_lock;
|
|
|
c7ffa4 |
-} nspu_desc_t;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-int nfp_nspu_init(nspu_desc_t *desc, int nfp, int pcie_bar, size_t pcie_barsz,
|
|
|
c7ffa4 |
- int exp_bar, void *exp_bar_cfg_base, void *exp_bar_mmap);
|
|
|
c7ffa4 |
-int nfp_nsp_get_abi_version(nspu_desc_t *desc, int *major, int *minor);
|
|
|
c7ffa4 |
-int nfp_nsp_fw_setup(nspu_desc_t *desc, const char *sym, uint64_t *pcie_offset);
|
|
|
c7ffa4 |
-int nfp_nsp_map_ctrl_bar(nspu_desc_t *desc, uint64_t *pcie_offset);
|
|
|
c7ffa4 |
-void nfp_nsp_map_queues_bar(nspu_desc_t *desc, uint64_t *pcie_offset);
|
|
|
c7ffa4 |
-int nfp_nsp_eth_config(nspu_desc_t *desc, int port, int up);
|
|
|
c7ffa4 |
-int nfp_nsp_eth_read_table(nspu_desc_t *desc, union eth_table_entry **table);
|
|
|
c7ffa4 |
--
|
|
|
c7ffa4 |
2.14.3
|
|
|
c7ffa4 |
|