summaryrefslogtreecommitdiffstats
path: root/drivers/net/nfp
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@gmail.com>2017-11-13 10:38:04 +0000
committerLuca Boccassi <luca.boccassi@gmail.com>2017-11-13 10:38:39 +0000
commit976be7358289d46cd5ed8131bbf2e2c5a6838d3c (patch)
tree5e6f873dd1658446539f9d4621e2d16f559c867d /drivers/net/nfp
parent055c52583a2794da8ba1e85a48cce3832372b12f (diff)
New upstream version 17.11~rc4
Change-Id: I5cc288310eaa28cb8c2e475afce5e19f8c08ba1e Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
Diffstat (limited to 'drivers/net/nfp')
-rw-r--r--drivers/net/nfp/nfp_net.c2
-rw-r--r--drivers/net/nfp/nfp_nfpu.c5
-rw-r--r--drivers/net/nfp/nfp_nspu.c23
3 files changed, 28 insertions, 2 deletions
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 83dec061..0501156b 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -1038,6 +1038,8 @@ nfp_net_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
/* RTE_ETHDEV_QUEUE_STAT_CNTRS default value is 16 */
+ memset(&nfp_dev_stats, 0, sizeof(nfp_dev_stats));
+
/* reading per RX ring stats */
for (i = 0; i < dev->data->nb_rx_queues; i++) {
if (i == RTE_ETHDEV_QUEUE_STAT_CNTRS)
diff --git a/drivers/net/nfp/nfp_nfpu.c b/drivers/net/nfp/nfp_nfpu.c
index 5775d8da..f11afef3 100644
--- a/drivers/net/nfp/nfp_nfpu.c
+++ b/drivers/net/nfp/nfp_nfpu.c
@@ -75,8 +75,13 @@ nfpu_open(struct rte_pci_device *pci_dev, nfpu_desc_t *desc, int nfp)
/* barsz in log2 */
while (barsz >>= 1)
i++;
+
barsz = i;
+ /* Sanity check: we can assume any bar size less than 1MB an error */
+ if (barsz < 20)
+ return -1;
+
/* Getting address for NFP expansion BAR registers */
cfg_base = pci_dev->mem_resource[0].addr;
cfg_base = (uint8_t *)cfg_base + NFP_CFG_EXP_BAR_CFG_BASE;
diff --git a/drivers/net/nfp/nfp_nspu.c b/drivers/net/nfp/nfp_nspu.c
index 6ba940cb..f9089832 100644
--- a/drivers/net/nfp/nfp_nspu.c
+++ b/drivers/net/nfp/nfp_nspu.c
@@ -341,7 +341,12 @@ nfp_fw_upload(nspu_desc_t *nspu_desc)
return -ENOENT;
}
- fstat(fw_f, &file_stat);
+ if (fstat(fw_f, &file_stat) < 0) {
+ RTE_LOG(INFO, PMD, "Firmware file %s/%s size is unknown",
+ DEFAULT_FW_PATH, DEFAULT_FW_FILENAME);
+ close(fw_f);
+ return -ENOENT;
+ }
fsize = file_stat.st_size;
RTE_LOG(DEBUG, PMD, "Firmware file with size: %" PRIu64 "\n",
@@ -351,12 +356,14 @@ nfp_fw_upload(nspu_desc_t *nspu_desc)
RTE_LOG(INFO, PMD, "fw file too big: %" PRIu64
" bytes (%" PRIu64 " max)",
(uint64_t)fsize, (uint64_t)size);
+ close(fw_f);
return -EINVAL;
}
fw_buf = malloc((size_t)size);
if (!fw_buf) {
RTE_LOG(INFO, PMD, "malloc failed for fw buffer");
+ close(fw_f);
return -ENOMEM;
}
memset(fw_buf, 0, size);
@@ -367,12 +374,14 @@ nfp_fw_upload(nspu_desc_t *nspu_desc)
"Just %" PRIu64 " of %" PRIu64 " bytes read.",
(uint64_t)bytes, (uint64_t)fsize);
free(fw_buf);
+ close(fw_f);
return -EIO;
}
ret = nspu_command(nspu_desc, NSP_CMD_FW_LOAD, 0, 1, fw_buf, 0, bytes);
free(fw_buf);
+ close(fw_f);
return ret;
}
@@ -411,6 +420,9 @@ nfp_nspu_set_bar_from_symbl(nspu_desc_t *desc, const char *symbl,
int ret = 0;
sym_buf = malloc(desc->buf_size);
+ if (!sym_buf)
+ return -ENOMEM;
+
strncpy(sym_buf, symbl, strlen(symbl));
ret = nspu_command(desc, NSP_CMD_GET_SYMBOL, 1, 1, sym_buf,
NFP_SYM_DESC_LEN, strlen(symbl));
@@ -554,6 +566,7 @@ nfp_nsp_eth_config(nspu_desc_t *desc, int port, int up)
NSP_ETH_TABLE_SIZE, 0);
if (ret) {
rte_spinlock_unlock(&desc->nsp_lock);
+ free(entries);
return ret;
}
@@ -574,6 +587,7 @@ nfp_nsp_eth_config(nspu_desc_t *desc, int port, int up)
if (i == NSP_ETH_MAX_COUNT) {
rte_spinlock_unlock(&desc->nsp_lock);
+ free(entries);
return -EINVAL;
}
@@ -598,6 +612,7 @@ nfp_nsp_eth_config(nspu_desc_t *desc, int port, int up)
"Hw ethernet port %d configure failed\n", port);
}
rte_spinlock_unlock(&desc->nsp_lock);
+ free(entries);
return ret;
}
@@ -606,10 +621,14 @@ nfp_nsp_eth_read_table(nspu_desc_t *desc, union eth_table_entry **table)
{
int ret;
+ if (!table)
+ return -EINVAL;
+
RTE_LOG(INFO, PMD, "Reading hw ethernet table...\n");
+
/* port 0 allocates the eth table and read it using NSPU */
*table = malloc(NSP_ETH_TABLE_SIZE);
- if (!table)
+ if (!*table)
return -ENOMEM;
ret = nspu_command(desc, NSP_CMD_READ_ETH_TABLE, 1, 0, *table,