Skip to content

Commit

Permalink
net/ionic: support FW version
Browse files Browse the repository at this point in the history
Add support for reading the firmware version.

Signed-off-by: Alfredo Cardigliano <cardigliano@ntop.org>
Reviewed-by: Shannon Nelson <snelson@pensando.io>
  • Loading branch information
cardigliano authored and Ferruh Yigit committed Jan 20, 2020
1 parent 64b0815 commit eec10fb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/guides/nics/features/ionic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Packet type parsing = Y
Basic stats = Y
Extended stats = Y
Stats per queue = Y
FW version = Y
Linux UIO = Y
Linux VFIO = Y
x86-64 = Y
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ionic/ionic.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct ionic_adapter {
bool intrs[IONIC_INTR_CTRL_REGS_MAX];
bool is_mgmt_nic;
bool link_up;
char fw_version[IONIC_DEVINFO_FWVERS_BUFLEN];
struct rte_pci_device *pci_dev;
LIST_ENTRY(ionic_adapter) pci_adapters;
};
Expand Down
8 changes: 8 additions & 0 deletions drivers/net/ionic/ionic_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ionic_dev_setup(struct ionic_adapter *adapter)
struct ionic_dev *idev = &adapter->idev;
uint32_t sig;
u_char *bar0_base;
unsigned int i;

/* BAR0: dev_cmd and interrupts */
if (num_bars < 1) {
Expand Down Expand Up @@ -47,6 +48,13 @@ ionic_dev_setup(struct ionic_adapter *adapter)
return -EFAULT;
}

for (i = 0; i < IONIC_DEVINFO_FWVERS_BUFLEN; i++)
adapter->fw_version[i] =
ioread8(&idev->dev_info->fw_version[i]);
adapter->fw_version[IONIC_DEVINFO_FWVERS_BUFLEN - 1] = '\0';

IONIC_PRINT(DEBUG, "Firmware version: %s", adapter->fw_version);

/* BAR1: doorbells */
bar++;
if (num_bars < 2) {
Expand Down
20 changes: 20 additions & 0 deletions drivers/net/ionic/ionic_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ static int ionic_dev_xstats_get_names(struct rte_eth_dev *dev,
static int ionic_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
struct rte_eth_xstat_name *xstats_names, const uint64_t *ids,
unsigned int limit);
static int ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev,
char *fw_version, size_t fw_size);

int ionic_logtype;

Expand Down Expand Up @@ -122,6 +124,7 @@ static const struct eth_dev_ops ionic_eth_dev_ops = {
.xstats_reset = ionic_dev_xstats_reset,
.xstats_get_names = ionic_dev_xstats_get_names,
.xstats_get_names_by_id = ionic_dev_xstats_get_names_by_id,
.fw_version_get = ionic_dev_fw_version_get,
};

struct rte_ionic_xstats_name_off {
Expand Down Expand Up @@ -211,6 +214,23 @@ static const struct rte_ionic_xstats_name_off rte_ionic_xstats_strings[] = {
#define IONIC_NB_HW_STATS (sizeof(rte_ionic_xstats_strings) / \
sizeof(rte_ionic_xstats_strings[0]))

static int
ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev,
char *fw_version, size_t fw_size)
{
struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
struct ionic_adapter *adapter = lif->adapter;

if (fw_version == NULL || fw_size <= 0)
return -EINVAL;

snprintf(fw_version, fw_size, "%s",
adapter->fw_version);
fw_version[fw_size - 1] = '\0';

return 0;
}

/*
* Set device link up, enable tx.
*/
Expand Down

0 comments on commit eec10fb

Please sign in to comment.