|
@@ -54,10 +54,11 @@
|
|
|
#include "nfpcore/nfp_nffw.h"
|
|
|
#include "nfpcore/nfp_nsp.h"
|
|
|
#include "nfpcore/nfp6000_pcie.h"
|
|
|
-
|
|
|
+#include "nfp_app.h"
|
|
|
#include "nfp_net_ctrl.h"
|
|
|
#include "nfp_net.h"
|
|
|
#include "nfp_main.h"
|
|
|
+#include "nfp_port.h"
|
|
|
|
|
|
#define NFP_PF_CSR_SLICE_SIZE (32 * 1024)
|
|
|
|
|
@@ -142,14 +143,16 @@ err_area:
|
|
|
static void
|
|
|
nfp_net_get_mac_addr(struct nfp_net *nn, struct nfp_cpp *cpp, unsigned int id)
|
|
|
{
|
|
|
+ struct nfp_eth_table_port *eth_port;
|
|
|
struct nfp_net_dp *dp = &nn->dp;
|
|
|
u8 mac_addr[ETH_ALEN];
|
|
|
const char *mac_str;
|
|
|
char name[32];
|
|
|
|
|
|
- if (nn->eth_port) {
|
|
|
- ether_addr_copy(dp->netdev->dev_addr, nn->eth_port->mac_addr);
|
|
|
- ether_addr_copy(dp->netdev->perm_addr, nn->eth_port->mac_addr);
|
|
|
+ eth_port = __nfp_port_get_eth_port(nn->port);
|
|
|
+ if (eth_port) {
|
|
|
+ ether_addr_copy(dp->netdev->dev_addr, eth_port->mac_addr);
|
|
|
+ ether_addr_copy(dp->netdev->perm_addr, eth_port->mac_addr);
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -190,21 +193,17 @@ nfp_net_find_port(struct nfp_eth_table *eth_tbl, unsigned int id)
|
|
|
static unsigned int nfp_net_pf_get_num_ports(struct nfp_pf *pf)
|
|
|
{
|
|
|
char name[256];
|
|
|
- u16 interface;
|
|
|
- int pcie_pf;
|
|
|
int err = 0;
|
|
|
u64 val;
|
|
|
|
|
|
- interface = nfp_cpp_interface(pf->cpp);
|
|
|
- pcie_pf = NFP_CPP_INTERFACE_UNIT_of(interface);
|
|
|
-
|
|
|
- snprintf(name, sizeof(name), "nfd_cfg_pf%d_num_ports", pcie_pf);
|
|
|
+ snprintf(name, sizeof(name), "nfd_cfg_pf%u_num_ports",
|
|
|
+ nfp_cppcore_pcie_unit(pf->cpp));
|
|
|
|
|
|
val = nfp_rtsym_read_le(pf->cpp, name, &err);
|
|
|
- /* Default to one port */
|
|
|
+ /* Default to one port/vNIC */
|
|
|
if (err) {
|
|
|
if (err != -ENOENT)
|
|
|
- nfp_err(pf->cpp, "Unable to read adapter port count\n");
|
|
|
+ nfp_err(pf->cpp, "Unable to read adapter vNIC count\n");
|
|
|
val = 1;
|
|
|
}
|
|
|
|
|
@@ -220,7 +219,7 @@ nfp_net_pf_total_qcs(struct nfp_pf *pf, void __iomem *ctrl_bar,
|
|
|
min_qc = readl(ctrl_bar + start_off);
|
|
|
max_qc = min_qc;
|
|
|
|
|
|
- for (i = 0; i < pf->num_ports; i++) {
|
|
|
+ for (i = 0; i < pf->max_data_vnics; i++) {
|
|
|
/* To make our lives simpler only accept configuration where
|
|
|
* queues are allocated to PFs in order (queues of PFn all have
|
|
|
* indexes lower than PFn+1).
|
|
@@ -241,13 +240,9 @@ static u8 __iomem *nfp_net_pf_map_ctrl_bar(struct nfp_pf *pf)
|
|
|
const struct nfp_rtsym *ctrl_sym;
|
|
|
u8 __iomem *ctrl_bar;
|
|
|
char pf_symbol[256];
|
|
|
- u16 interface;
|
|
|
- int pcie_pf;
|
|
|
-
|
|
|
- interface = nfp_cpp_interface(pf->cpp);
|
|
|
- pcie_pf = NFP_CPP_INTERFACE_UNIT_of(interface);
|
|
|
|
|
|
- snprintf(pf_symbol, sizeof(pf_symbol), "_pf%d_net_bar0", pcie_pf);
|
|
|
+ snprintf(pf_symbol, sizeof(pf_symbol), "_pf%u_net_bar0",
|
|
|
+ nfp_cppcore_pcie_unit(pf->cpp));
|
|
|
|
|
|
ctrl_sym = nfp_rtsym_lookup(pf->cpp, pf_symbol);
|
|
|
if (!ctrl_sym) {
|
|
@@ -256,17 +251,17 @@ static u8 __iomem *nfp_net_pf_map_ctrl_bar(struct nfp_pf *pf)
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
- if (ctrl_sym->size < pf->num_ports * NFP_PF_CSR_SLICE_SIZE) {
|
|
|
+ if (ctrl_sym->size < pf->max_data_vnics * NFP_PF_CSR_SLICE_SIZE) {
|
|
|
dev_err(&pf->pdev->dev,
|
|
|
- "PF BAR0 too small to contain %d ports\n",
|
|
|
- pf->num_ports);
|
|
|
+ "PF BAR0 too small to contain %d vNICs\n",
|
|
|
+ pf->max_data_vnics);
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
ctrl_bar = nfp_net_map_area(pf->cpp, "net.ctrl",
|
|
|
ctrl_sym->domain, ctrl_sym->target,
|
|
|
ctrl_sym->addr, ctrl_sym->size,
|
|
|
- &pf->ctrl_area);
|
|
|
+ &pf->data_vnic_bar);
|
|
|
if (IS_ERR(ctrl_bar)) {
|
|
|
dev_err(&pf->pdev->dev, "Failed to map PF BAR0: %ld\n",
|
|
|
PTR_ERR(ctrl_bar));
|
|
@@ -276,37 +271,43 @@ static u8 __iomem *nfp_net_pf_map_ctrl_bar(struct nfp_pf *pf)
|
|
|
return ctrl_bar;
|
|
|
}
|
|
|
|
|
|
-static void nfp_net_pf_free_netdevs(struct nfp_pf *pf)
|
|
|
+static void nfp_net_pf_free_vnic(struct nfp_pf *pf, struct nfp_net *nn)
|
|
|
{
|
|
|
- struct nfp_net *nn;
|
|
|
+ nfp_port_free(nn->port);
|
|
|
+ list_del(&nn->vnic_list);
|
|
|
+ pf->num_vnics--;
|
|
|
+ nfp_net_free(nn);
|
|
|
+}
|
|
|
|
|
|
- while (!list_empty(&pf->ports)) {
|
|
|
- nn = list_first_entry(&pf->ports, struct nfp_net, port_list);
|
|
|
- list_del(&nn->port_list);
|
|
|
- pf->num_netdevs--;
|
|
|
+static void nfp_net_pf_free_vnics(struct nfp_pf *pf)
|
|
|
+{
|
|
|
+ struct nfp_net *nn;
|
|
|
|
|
|
- nfp_net_netdev_free(nn);
|
|
|
+ while (!list_empty(&pf->vnics)) {
|
|
|
+ nn = list_first_entry(&pf->vnics, struct nfp_net, vnic_list);
|
|
|
+ nfp_net_pf_free_vnic(pf, nn);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static struct nfp_net *
|
|
|
-nfp_net_pf_alloc_port_netdev(struct nfp_pf *pf, void __iomem *ctrl_bar,
|
|
|
- void __iomem *tx_bar, void __iomem *rx_bar,
|
|
|
- int stride, struct nfp_net_fw_version *fw_ver,
|
|
|
- struct nfp_eth_table_port *eth_port)
|
|
|
+nfp_net_pf_alloc_vnic(struct nfp_pf *pf, void __iomem *ctrl_bar,
|
|
|
+ void __iomem *tx_bar, void __iomem *rx_bar,
|
|
|
+ int stride, struct nfp_net_fw_version *fw_ver,
|
|
|
+ unsigned int eth_id)
|
|
|
{
|
|
|
+ struct nfp_eth_table_port *eth_port;
|
|
|
u32 n_tx_rings, n_rx_rings;
|
|
|
struct nfp_net *nn;
|
|
|
|
|
|
n_tx_rings = readl(ctrl_bar + NFP_NET_CFG_MAX_TXRINGS);
|
|
|
n_rx_rings = readl(ctrl_bar + NFP_NET_CFG_MAX_RXRINGS);
|
|
|
|
|
|
- /* Allocate and initialise the netdev */
|
|
|
- nn = nfp_net_netdev_alloc(pf->pdev, n_tx_rings, n_rx_rings);
|
|
|
+ /* Allocate and initialise the vNIC */
|
|
|
+ nn = nfp_net_alloc(pf->pdev, n_tx_rings, n_rx_rings);
|
|
|
if (IS_ERR(nn))
|
|
|
return nn;
|
|
|
|
|
|
- nn->cpp = pf->cpp;
|
|
|
+ nn->app = pf->app;
|
|
|
nn->fw_ver = *fw_ver;
|
|
|
nn->dp.ctrl_bar = ctrl_bar;
|
|
|
nn->tx_bar = tx_bar;
|
|
@@ -314,14 +315,27 @@ nfp_net_pf_alloc_port_netdev(struct nfp_pf *pf, void __iomem *ctrl_bar,
|
|
|
nn->dp.is_vf = 0;
|
|
|
nn->stride_rx = stride;
|
|
|
nn->stride_tx = stride;
|
|
|
- nn->eth_port = eth_port;
|
|
|
+
|
|
|
+ eth_port = nfp_net_find_port(pf->eth_tbl, eth_id);
|
|
|
+ if (eth_port) {
|
|
|
+ nn->port = nfp_port_alloc(pf->app, NFP_PORT_PHYS_PORT,
|
|
|
+ nn->dp.netdev);
|
|
|
+ if (IS_ERR(nn->port)) {
|
|
|
+ nfp_net_free(nn);
|
|
|
+ return ERR_CAST(nn->port);
|
|
|
+ }
|
|
|
+ nn->port->eth_id = eth_id;
|
|
|
+ nn->port->eth_port = eth_port;
|
|
|
+ }
|
|
|
+
|
|
|
+ pf->num_vnics++;
|
|
|
+ list_add_tail(&nn->vnic_list, &pf->vnics);
|
|
|
|
|
|
return nn;
|
|
|
}
|
|
|
|
|
|
static int
|
|
|
-nfp_net_pf_init_port_netdev(struct nfp_pf *pf, struct nfp_net *nn,
|
|
|
- unsigned int id)
|
|
|
+nfp_net_pf_init_vnic(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id)
|
|
|
{
|
|
|
int err;
|
|
|
|
|
@@ -334,11 +348,11 @@ nfp_net_pf_init_port_netdev(struct nfp_pf *pf, struct nfp_net *nn,
|
|
|
*/
|
|
|
nn->me_freq_mhz = 1200;
|
|
|
|
|
|
- err = nfp_net_netdev_init(nn->dp.netdev);
|
|
|
+ err = nfp_net_init(nn);
|
|
|
if (err)
|
|
|
return err;
|
|
|
|
|
|
- nfp_net_debugfs_port_add(nn, pf->ddir, id);
|
|
|
+ nfp_net_debugfs_vnic_add(nn, pf->ddir, id);
|
|
|
|
|
|
nfp_net_info(nn);
|
|
|
|
|
@@ -346,20 +360,25 @@ nfp_net_pf_init_port_netdev(struct nfp_pf *pf, struct nfp_net *nn,
|
|
|
}
|
|
|
|
|
|
static int
|
|
|
-nfp_net_pf_alloc_netdevs(struct nfp_pf *pf, void __iomem *ctrl_bar,
|
|
|
- void __iomem *tx_bar, void __iomem *rx_bar,
|
|
|
- int stride, struct nfp_net_fw_version *fw_ver)
|
|
|
+nfp_net_pf_alloc_vnics(struct nfp_pf *pf, void __iomem *ctrl_bar,
|
|
|
+ void __iomem *tx_bar, void __iomem *rx_bar,
|
|
|
+ int stride, struct nfp_net_fw_version *fw_ver)
|
|
|
{
|
|
|
u32 prev_tx_base, prev_rx_base, tgt_tx_base, tgt_rx_base;
|
|
|
- struct nfp_eth_table_port *eth_port;
|
|
|
struct nfp_net *nn;
|
|
|
unsigned int i;
|
|
|
int err;
|
|
|
|
|
|
+ if (pf->eth_tbl && pf->max_data_vnics != pf->eth_tbl->count) {
|
|
|
+ nfp_err(pf->cpp, "ETH entries don't match vNICs (%d vs %d)\n",
|
|
|
+ pf->max_data_vnics, pf->eth_tbl->count);
|
|
|
+ return -EINVAL;
|
|
|
+ }
|
|
|
+
|
|
|
prev_tx_base = readl(ctrl_bar + NFP_NET_CFG_START_TXQ);
|
|
|
prev_rx_base = readl(ctrl_bar + NFP_NET_CFG_START_RXQ);
|
|
|
|
|
|
- for (i = 0; i < pf->num_ports; i++) {
|
|
|
+ for (i = 0; i < pf->max_data_vnics; i++) {
|
|
|
tgt_tx_base = readl(ctrl_bar + NFP_NET_CFG_START_TXQ);
|
|
|
tgt_rx_base = readl(ctrl_bar + NFP_NET_CFG_START_RXQ);
|
|
|
tx_bar += (tgt_tx_base - prev_tx_base) * NFP_QCP_QUEUE_ADDR_SZ;
|
|
@@ -367,53 +386,57 @@ nfp_net_pf_alloc_netdevs(struct nfp_pf *pf, void __iomem *ctrl_bar,
|
|
|
prev_tx_base = tgt_tx_base;
|
|
|
prev_rx_base = tgt_rx_base;
|
|
|
|
|
|
- eth_port = nfp_net_find_port(pf->eth_tbl, i);
|
|
|
- if (eth_port && eth_port->override_changed) {
|
|
|
- nfp_warn(pf->cpp, "Config changed for port #%d, reboot required before port will be operational\n", i);
|
|
|
- } else {
|
|
|
- nn = nfp_net_pf_alloc_port_netdev(pf, ctrl_bar, tx_bar,
|
|
|
- rx_bar, stride,
|
|
|
- fw_ver, eth_port);
|
|
|
- if (IS_ERR(nn)) {
|
|
|
- err = PTR_ERR(nn);
|
|
|
- goto err_free_prev;
|
|
|
- }
|
|
|
- list_add_tail(&nn->port_list, &pf->ports);
|
|
|
- pf->num_netdevs++;
|
|
|
+ nn = nfp_net_pf_alloc_vnic(pf, ctrl_bar, tx_bar, rx_bar,
|
|
|
+ stride, fw_ver, i);
|
|
|
+ if (IS_ERR(nn)) {
|
|
|
+ err = PTR_ERR(nn);
|
|
|
+ goto err_free_prev;
|
|
|
}
|
|
|
|
|
|
ctrl_bar += NFP_PF_CSR_SLICE_SIZE;
|
|
|
+
|
|
|
+ /* Check if vNIC has external port associated and cfg is OK */
|
|
|
+ if (pf->eth_tbl && !nn->port) {
|
|
|
+ nfp_err(pf->cpp, "NSP port entries don't match vNICs (no entry for port #%d)\n", i);
|
|
|
+ err = -EINVAL;
|
|
|
+ goto err_free_prev;
|
|
|
+ }
|
|
|
+ if (nn->port && nn->port->eth_port->override_changed) {
|
|
|
+ nfp_warn(pf->cpp, "Config changed for port #%d, reboot required before port will be operational\n", i);
|
|
|
+ nfp_net_pf_free_vnic(pf, nn);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (list_empty(&pf->ports))
|
|
|
+ if (list_empty(&pf->vnics))
|
|
|
return -ENODEV;
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
err_free_prev:
|
|
|
- nfp_net_pf_free_netdevs(pf);
|
|
|
+ nfp_net_pf_free_vnics(pf);
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
static int
|
|
|
-nfp_net_pf_spawn_netdevs(struct nfp_pf *pf,
|
|
|
- void __iomem *ctrl_bar, void __iomem *tx_bar,
|
|
|
- void __iomem *rx_bar, int stride,
|
|
|
- struct nfp_net_fw_version *fw_ver)
|
|
|
+nfp_net_pf_spawn_vnics(struct nfp_pf *pf,
|
|
|
+ void __iomem *ctrl_bar, void __iomem *tx_bar,
|
|
|
+ void __iomem *rx_bar, int stride,
|
|
|
+ struct nfp_net_fw_version *fw_ver)
|
|
|
{
|
|
|
- unsigned int id, wanted_irqs, num_irqs, ports_left, irqs_left;
|
|
|
+ unsigned int id, wanted_irqs, num_irqs, vnics_left, irqs_left;
|
|
|
struct nfp_net *nn;
|
|
|
int err;
|
|
|
|
|
|
- /* Allocate the netdevs and do basic init */
|
|
|
- err = nfp_net_pf_alloc_netdevs(pf, ctrl_bar, tx_bar, rx_bar,
|
|
|
- stride, fw_ver);
|
|
|
+ /* Allocate the vnics and do basic init */
|
|
|
+ err = nfp_net_pf_alloc_vnics(pf, ctrl_bar, tx_bar, rx_bar,
|
|
|
+ stride, fw_ver);
|
|
|
if (err)
|
|
|
return err;
|
|
|
|
|
|
/* Get MSI-X vectors */
|
|
|
wanted_irqs = 0;
|
|
|
- list_for_each_entry(nn, &pf->ports, port_list)
|
|
|
+ list_for_each_entry(nn, &pf->vnics, vnic_list)
|
|
|
wanted_irqs += NFP_NET_NON_Q_VECTORS + nn->dp.num_r_vecs;
|
|
|
pf->irq_entries = kcalloc(wanted_irqs, sizeof(*pf->irq_entries),
|
|
|
GFP_KERNEL);
|
|
@@ -423,7 +446,7 @@ nfp_net_pf_spawn_netdevs(struct nfp_pf *pf,
|
|
|
}
|
|
|
|
|
|
num_irqs = nfp_net_irqs_alloc(pf->pdev, pf->irq_entries,
|
|
|
- NFP_NET_MIN_PORT_IRQS * pf->num_netdevs,
|
|
|
+ NFP_NET_MIN_VNIC_IRQS * pf->num_vnics,
|
|
|
wanted_irqs);
|
|
|
if (!num_irqs) {
|
|
|
nn_warn(nn, "Unable to allocate MSI-X Vectors. Exiting\n");
|
|
@@ -431,23 +454,23 @@ nfp_net_pf_spawn_netdevs(struct nfp_pf *pf,
|
|
|
goto err_vec_free;
|
|
|
}
|
|
|
|
|
|
- /* Distribute IRQs to ports */
|
|
|
+ /* Distribute IRQs to vNICs */
|
|
|
irqs_left = num_irqs;
|
|
|
- ports_left = pf->num_netdevs;
|
|
|
- list_for_each_entry(nn, &pf->ports, port_list) {
|
|
|
+ vnics_left = pf->num_vnics;
|
|
|
+ list_for_each_entry(nn, &pf->vnics, vnic_list) {
|
|
|
unsigned int n;
|
|
|
|
|
|
- n = DIV_ROUND_UP(irqs_left, ports_left);
|
|
|
+ n = DIV_ROUND_UP(irqs_left, vnics_left);
|
|
|
nfp_net_irqs_assign(nn, &pf->irq_entries[num_irqs - irqs_left],
|
|
|
n);
|
|
|
irqs_left -= n;
|
|
|
- ports_left--;
|
|
|
+ vnics_left--;
|
|
|
}
|
|
|
|
|
|
- /* Finish netdev init and register */
|
|
|
+ /* Finish vNIC init and register */
|
|
|
id = 0;
|
|
|
- list_for_each_entry(nn, &pf->ports, port_list) {
|
|
|
- err = nfp_net_pf_init_port_netdev(pf, nn, id);
|
|
|
+ list_for_each_entry(nn, &pf->vnics, vnic_list) {
|
|
|
+ err = nfp_net_pf_init_vnic(pf, nn, id);
|
|
|
if (err)
|
|
|
goto err_prev_deinit;
|
|
|
|
|
@@ -457,18 +480,30 @@ nfp_net_pf_spawn_netdevs(struct nfp_pf *pf,
|
|
|
return 0;
|
|
|
|
|
|
err_prev_deinit:
|
|
|
- list_for_each_entry_continue_reverse(nn, &pf->ports, port_list) {
|
|
|
+ list_for_each_entry_continue_reverse(nn, &pf->vnics, vnic_list) {
|
|
|
nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
|
|
|
- nfp_net_netdev_clean(nn->dp.netdev);
|
|
|
+ nfp_net_clean(nn);
|
|
|
}
|
|
|
nfp_net_irqs_disable(pf->pdev);
|
|
|
err_vec_free:
|
|
|
kfree(pf->irq_entries);
|
|
|
err_nn_free:
|
|
|
- nfp_net_pf_free_netdevs(pf);
|
|
|
+ nfp_net_pf_free_vnics(pf);
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
+static int nfp_net_pf_app_init(struct nfp_pf *pf)
|
|
|
+{
|
|
|
+ pf->app = nfp_app_alloc(pf);
|
|
|
+
|
|
|
+ return PTR_ERR_OR_ZERO(pf->app);
|
|
|
+}
|
|
|
+
|
|
|
+static void nfp_net_pf_app_clean(struct nfp_pf *pf)
|
|
|
+{
|
|
|
+ nfp_app_free(pf->app);
|
|
|
+}
|
|
|
+
|
|
|
static void nfp_net_pci_remove_finish(struct nfp_pf *pf)
|
|
|
{
|
|
|
nfp_net_debugfs_dir_clean(&pf->ddir);
|
|
@@ -476,99 +511,120 @@ static void nfp_net_pci_remove_finish(struct nfp_pf *pf)
|
|
|
nfp_net_irqs_disable(pf->pdev);
|
|
|
kfree(pf->irq_entries);
|
|
|
|
|
|
+ nfp_net_pf_app_clean(pf);
|
|
|
+
|
|
|
nfp_cpp_area_release_free(pf->rx_area);
|
|
|
nfp_cpp_area_release_free(pf->tx_area);
|
|
|
- nfp_cpp_area_release_free(pf->ctrl_area);
|
|
|
+ nfp_cpp_area_release_free(pf->data_vnic_bar);
|
|
|
}
|
|
|
|
|
|
-static void nfp_net_refresh_netdevs(struct work_struct *work)
|
|
|
+static int
|
|
|
+nfp_net_eth_port_update(struct nfp_cpp *cpp, struct nfp_port *port,
|
|
|
+ struct nfp_eth_table *eth_table)
|
|
|
+{
|
|
|
+ struct nfp_eth_table_port *eth_port;
|
|
|
+
|
|
|
+ ASSERT_RTNL();
|
|
|
+
|
|
|
+ eth_port = nfp_net_find_port(eth_table, port->eth_id);
|
|
|
+ if (!eth_port) {
|
|
|
+ set_bit(NFP_PORT_CHANGED, &port->flags);
|
|
|
+ nfp_warn(cpp, "Warning: port #%d not present after reconfig\n",
|
|
|
+ port->eth_id);
|
|
|
+ return -EIO;
|
|
|
+ }
|
|
|
+ if (eth_port->override_changed) {
|
|
|
+ nfp_warn(cpp, "Port #%d config changed, unregistering. Reboot required before port will be operational again.\n", port->eth_id);
|
|
|
+ port->type = NFP_PORT_INVALID;
|
|
|
+ }
|
|
|
+
|
|
|
+ memcpy(port->eth_port, eth_port, sizeof(*eth_port));
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+static void nfp_net_refresh_vnics(struct work_struct *work)
|
|
|
{
|
|
|
struct nfp_pf *pf = container_of(work, struct nfp_pf,
|
|
|
port_refresh_work);
|
|
|
struct nfp_eth_table *eth_table;
|
|
|
struct nfp_net *nn, *next;
|
|
|
+ struct nfp_port *port;
|
|
|
|
|
|
- mutex_lock(&pf->port_lock);
|
|
|
+ mutex_lock(&pf->lock);
|
|
|
|
|
|
/* Check for nfp_net_pci_remove() racing against us */
|
|
|
- if (list_empty(&pf->ports))
|
|
|
+ if (list_empty(&pf->vnics))
|
|
|
goto out;
|
|
|
|
|
|
- list_for_each_entry(nn, &pf->ports, port_list)
|
|
|
- nfp_net_link_changed_read_clear(nn);
|
|
|
+ /* Update state of all ports */
|
|
|
+ rtnl_lock();
|
|
|
+ list_for_each_entry(port, &pf->ports, port_list)
|
|
|
+ clear_bit(NFP_PORT_CHANGED, &port->flags);
|
|
|
|
|
|
eth_table = nfp_eth_read_ports(pf->cpp);
|
|
|
if (!eth_table) {
|
|
|
+ list_for_each_entry(port, &pf->ports, port_list)
|
|
|
+ if (__nfp_port_get_eth_port(port))
|
|
|
+ set_bit(NFP_PORT_CHANGED, &port->flags);
|
|
|
+ rtnl_unlock();
|
|
|
nfp_err(pf->cpp, "Error refreshing port config!\n");
|
|
|
goto out;
|
|
|
}
|
|
|
|
|
|
- rtnl_lock();
|
|
|
- list_for_each_entry(nn, &pf->ports, port_list) {
|
|
|
- if (!nn->eth_port)
|
|
|
- continue;
|
|
|
- nn->eth_port = nfp_net_find_port(eth_table,
|
|
|
- nn->eth_port->eth_index);
|
|
|
- }
|
|
|
+ list_for_each_entry(port, &pf->ports, port_list)
|
|
|
+ if (__nfp_port_get_eth_port(port))
|
|
|
+ nfp_net_eth_port_update(pf->cpp, port, eth_table);
|
|
|
rtnl_unlock();
|
|
|
|
|
|
- kfree(pf->eth_tbl);
|
|
|
- pf->eth_tbl = eth_table;
|
|
|
+ kfree(eth_table);
|
|
|
|
|
|
- list_for_each_entry_safe(nn, next, &pf->ports, port_list) {
|
|
|
- if (!nn->eth_port) {
|
|
|
- nfp_warn(pf->cpp, "Warning: port not present after reconfig\n");
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (!nn->eth_port->override_changed)
|
|
|
+ /* Shoot off the ports which became invalid */
|
|
|
+ list_for_each_entry_safe(nn, next, &pf->vnics, vnic_list) {
|
|
|
+ if (!nn->port || nn->port->type != NFP_PORT_INVALID)
|
|
|
continue;
|
|
|
|
|
|
- nn_warn(nn, "Port config changed, unregistering. Reboot required before port will be operational again.\n");
|
|
|
-
|
|
|
nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
|
|
|
- nfp_net_netdev_clean(nn->dp.netdev);
|
|
|
+ nfp_net_clean(nn);
|
|
|
|
|
|
- list_del(&nn->port_list);
|
|
|
- pf->num_netdevs--;
|
|
|
- nfp_net_netdev_free(nn);
|
|
|
+ nfp_net_pf_free_vnic(pf, nn);
|
|
|
}
|
|
|
|
|
|
- if (list_empty(&pf->ports))
|
|
|
+ if (list_empty(&pf->vnics))
|
|
|
nfp_net_pci_remove_finish(pf);
|
|
|
out:
|
|
|
- mutex_unlock(&pf->port_lock);
|
|
|
+ mutex_unlock(&pf->lock);
|
|
|
}
|
|
|
|
|
|
-void nfp_net_refresh_port_table(struct nfp_net *nn)
|
|
|
+void nfp_net_refresh_port_table(struct nfp_port *port)
|
|
|
{
|
|
|
- struct nfp_pf *pf = pci_get_drvdata(nn->pdev);
|
|
|
+ struct nfp_pf *pf = port->app->pf;
|
|
|
+
|
|
|
+ set_bit(NFP_PORT_CHANGED, &port->flags);
|
|
|
|
|
|
schedule_work(&pf->port_refresh_work);
|
|
|
}
|
|
|
|
|
|
-int nfp_net_refresh_eth_port(struct nfp_net *nn)
|
|
|
+int nfp_net_refresh_eth_port(struct nfp_port *port)
|
|
|
{
|
|
|
- struct nfp_eth_table_port *eth_port;
|
|
|
+ struct nfp_cpp *cpp = port->app->cpp;
|
|
|
struct nfp_eth_table *eth_table;
|
|
|
+ int ret;
|
|
|
|
|
|
- eth_table = nfp_eth_read_ports(nn->cpp);
|
|
|
- if (!eth_table) {
|
|
|
- nn_err(nn, "Error refreshing port state table!\n");
|
|
|
- return -EIO;
|
|
|
- }
|
|
|
+ clear_bit(NFP_PORT_CHANGED, &port->flags);
|
|
|
|
|
|
- eth_port = nfp_net_find_port(eth_table, nn->eth_port->eth_index);
|
|
|
- if (!eth_port) {
|
|
|
- nn_err(nn, "Error finding state of the port!\n");
|
|
|
- kfree(eth_table);
|
|
|
+ eth_table = nfp_eth_read_ports(cpp);
|
|
|
+ if (!eth_table) {
|
|
|
+ set_bit(NFP_PORT_CHANGED, &port->flags);
|
|
|
+ nfp_err(cpp, "Error refreshing port state table!\n");
|
|
|
return -EIO;
|
|
|
}
|
|
|
|
|
|
- memcpy(nn->eth_port, eth_port, sizeof(*eth_port));
|
|
|
+ ret = nfp_net_eth_port_update(cpp, port, eth_table);
|
|
|
|
|
|
kfree(eth_table);
|
|
|
|
|
|
- return 0;
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -584,8 +640,8 @@ int nfp_net_pci_probe(struct nfp_pf *pf)
|
|
|
int stride;
|
|
|
int err;
|
|
|
|
|
|
- INIT_WORK(&pf->port_refresh_work, nfp_net_refresh_netdevs);
|
|
|
- mutex_init(&pf->port_lock);
|
|
|
+ INIT_WORK(&pf->port_refresh_work, nfp_net_refresh_vnics);
|
|
|
+ mutex_init(&pf->lock);
|
|
|
|
|
|
/* Verify that the board has completed initialization */
|
|
|
if (!nfp_is_ready(pf->cpp)) {
|
|
@@ -593,8 +649,8 @@ int nfp_net_pci_probe(struct nfp_pf *pf)
|
|
|
return -EINVAL;
|
|
|
}
|
|
|
|
|
|
- mutex_lock(&pf->port_lock);
|
|
|
- pf->num_ports = nfp_net_pf_get_num_ports(pf);
|
|
|
+ mutex_lock(&pf->lock);
|
|
|
+ pf->max_data_vnics = nfp_net_pf_get_num_ports(pf);
|
|
|
|
|
|
ctrl_bar = nfp_net_pf_map_ctrl_bar(pf);
|
|
|
if (!ctrl_bar) {
|
|
@@ -667,26 +723,32 @@ int nfp_net_pci_probe(struct nfp_pf *pf)
|
|
|
goto err_unmap_tx;
|
|
|
}
|
|
|
|
|
|
+ err = nfp_net_pf_app_init(pf);
|
|
|
+ if (err)
|
|
|
+ goto err_unmap_rx;
|
|
|
+
|
|
|
pf->ddir = nfp_net_debugfs_device_add(pf->pdev);
|
|
|
|
|
|
- err = nfp_net_pf_spawn_netdevs(pf, ctrl_bar, tx_bar, rx_bar,
|
|
|
- stride, &fw_ver);
|
|
|
+ err = nfp_net_pf_spawn_vnics(pf, ctrl_bar, tx_bar, rx_bar,
|
|
|
+ stride, &fw_ver);
|
|
|
if (err)
|
|
|
goto err_clean_ddir;
|
|
|
|
|
|
- mutex_unlock(&pf->port_lock);
|
|
|
+ mutex_unlock(&pf->lock);
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
err_clean_ddir:
|
|
|
nfp_net_debugfs_dir_clean(&pf->ddir);
|
|
|
+ nfp_net_pf_app_clean(pf);
|
|
|
+err_unmap_rx:
|
|
|
nfp_cpp_area_release_free(pf->rx_area);
|
|
|
err_unmap_tx:
|
|
|
nfp_cpp_area_release_free(pf->tx_area);
|
|
|
err_ctrl_unmap:
|
|
|
- nfp_cpp_area_release_free(pf->ctrl_area);
|
|
|
+ nfp_cpp_area_release_free(pf->data_vnic_bar);
|
|
|
err_unlock:
|
|
|
- mutex_unlock(&pf->port_lock);
|
|
|
+ mutex_unlock(&pf->lock);
|
|
|
return err;
|
|
|
}
|
|
|
|
|
@@ -694,21 +756,21 @@ void nfp_net_pci_remove(struct nfp_pf *pf)
|
|
|
{
|
|
|
struct nfp_net *nn;
|
|
|
|
|
|
- mutex_lock(&pf->port_lock);
|
|
|
- if (list_empty(&pf->ports))
|
|
|
+ mutex_lock(&pf->lock);
|
|
|
+ if (list_empty(&pf->vnics))
|
|
|
goto out;
|
|
|
|
|
|
- list_for_each_entry(nn, &pf->ports, port_list) {
|
|
|
+ list_for_each_entry(nn, &pf->vnics, vnic_list) {
|
|
|
nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
|
|
|
|
|
|
- nfp_net_netdev_clean(nn->dp.netdev);
|
|
|
+ nfp_net_clean(nn);
|
|
|
}
|
|
|
|
|
|
- nfp_net_pf_free_netdevs(pf);
|
|
|
+ nfp_net_pf_free_vnics(pf);
|
|
|
|
|
|
nfp_net_pci_remove_finish(pf);
|
|
|
out:
|
|
|
- mutex_unlock(&pf->port_lock);
|
|
|
+ mutex_unlock(&pf->lock);
|
|
|
|
|
|
cancel_work_sync(&pf->port_refresh_work);
|
|
|
}
|