Commit bd5ca062 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: report NSP ABI version in ethtool FW version

ethtool_drvinfo->fw_version can cantain multiple FW strings.
We already report NFD ABI version there, add NSP ABI version
if available (i.e. on PF) with 'sp:' prefix.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 368b1d1c
...@@ -111,6 +111,7 @@ ...@@ -111,6 +111,7 @@
SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
/* Forward declarations */ /* Forward declarations */
struct nfp_cpp;
struct nfp_net; struct nfp_net;
struct nfp_net_r_vector; struct nfp_net_r_vector;
...@@ -492,6 +493,7 @@ struct nfp_stat_pair { ...@@ -492,6 +493,7 @@ struct nfp_stat_pair {
* @rx_bar: Pointer to mapped FL/RX queues * @rx_bar: Pointer to mapped FL/RX queues
* @debugfs_dir: Device directory in debugfs * @debugfs_dir: Device directory in debugfs
* @port_list: Entry on device port list * @port_list: Entry on device port list
* @cpp: CPP device handle if available
*/ */
struct nfp_net { struct nfp_net {
struct pci_dev *pdev; struct pci_dev *pdev;
...@@ -579,6 +581,8 @@ struct nfp_net { ...@@ -579,6 +581,8 @@ struct nfp_net {
struct dentry *debugfs_dir; struct dentry *debugfs_dir;
struct list_head port_list; struct list_head port_list;
struct nfp_cpp *cpp;
}; };
struct nfp_net_ring_set { struct nfp_net_ring_set {
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include "nfpcore/nfp.h"
#include "nfp_net_ctrl.h" #include "nfp_net_ctrl.h"
#include "nfp_net.h" #include "nfp_net.h"
...@@ -127,19 +128,39 @@ static const struct _nfp_net_et_stats nfp_net_et_stats[] = { ...@@ -127,19 +128,39 @@ static const struct _nfp_net_et_stats nfp_net_et_stats[] = {
#define NN_ET_STATS_LEN (NN_ET_GLOBAL_STATS_LEN + NN_ET_RVEC_GATHER_STATS + \ #define NN_ET_STATS_LEN (NN_ET_GLOBAL_STATS_LEN + NN_ET_RVEC_GATHER_STATS + \
NN_ET_RVEC_STATS_LEN + NN_ET_QUEUE_STATS_LEN) NN_ET_RVEC_STATS_LEN + NN_ET_QUEUE_STATS_LEN)
static void nfp_net_get_nspinfo(struct nfp_net *nn, char *version)
{
struct nfp_nsp *nsp;
if (!nn->cpp)
return;
nsp = nfp_nsp_open(nn->cpp);
if (IS_ERR(nsp))
return;
snprintf(version, ETHTOOL_FWVERS_LEN, "sp:%hu.%hu",
nfp_nsp_get_abi_ver_major(nsp),
nfp_nsp_get_abi_ver_minor(nsp));
nfp_nsp_close(nsp);
}
static void nfp_net_get_drvinfo(struct net_device *netdev, static void nfp_net_get_drvinfo(struct net_device *netdev,
struct ethtool_drvinfo *drvinfo) struct ethtool_drvinfo *drvinfo)
{ {
char nsp_version[ETHTOOL_FWVERS_LEN] = {};
struct nfp_net *nn = netdev_priv(netdev); struct nfp_net *nn = netdev_priv(netdev);
strlcpy(drvinfo->driver, nn->pdev->driver->name, strlcpy(drvinfo->driver, nn->pdev->driver->name,
sizeof(drvinfo->driver)); sizeof(drvinfo->driver));
strlcpy(drvinfo->version, nfp_driver_version, sizeof(drvinfo->version)); strlcpy(drvinfo->version, nfp_driver_version, sizeof(drvinfo->version));
nfp_net_get_nspinfo(nn, nsp_version);
snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
"%d.%d.%d.%d", "%d.%d.%d.%d %s",
nn->fw_ver.resv, nn->fw_ver.class, nn->fw_ver.resv, nn->fw_ver.class,
nn->fw_ver.major, nn->fw_ver.minor); nn->fw_ver.major, nn->fw_ver.minor, nsp_version);
strlcpy(drvinfo->bus_info, pci_name(nn->pdev), strlcpy(drvinfo->bus_info, pci_name(nn->pdev),
sizeof(drvinfo->bus_info)); sizeof(drvinfo->bus_info));
......
...@@ -303,6 +303,7 @@ nfp_net_pf_alloc_port_netdev(struct nfp_pf *pf, void __iomem *ctrl_bar, ...@@ -303,6 +303,7 @@ nfp_net_pf_alloc_port_netdev(struct nfp_pf *pf, void __iomem *ctrl_bar,
if (IS_ERR(nn)) if (IS_ERR(nn))
return nn; return nn;
nn->cpp = pf->cpp;
nn->fw_ver = *fw_ver; nn->fw_ver = *fw_ver;
nn->ctrl_bar = ctrl_bar; nn->ctrl_bar = ctrl_bar;
nn->tx_bar = tx_bar; nn->tx_bar = tx_bar;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#define __NFP_H__ #define __NFP_H__
#include <linux/device.h> #include <linux/device.h>
#include <linux/types.h>
#include "nfp_cpp.h" #include "nfp_cpp.h"
...@@ -54,6 +55,8 @@ struct firmware; ...@@ -54,6 +55,8 @@ struct firmware;
struct nfp_nsp *nfp_nsp_open(struct nfp_cpp *cpp); struct nfp_nsp *nfp_nsp_open(struct nfp_cpp *cpp);
void nfp_nsp_close(struct nfp_nsp *state); void nfp_nsp_close(struct nfp_nsp *state);
u16 nfp_nsp_get_abi_ver_major(struct nfp_nsp *state);
u16 nfp_nsp_get_abi_ver_minor(struct nfp_nsp *state);
int nfp_nsp_wait(struct nfp_nsp *state); int nfp_nsp_wait(struct nfp_nsp *state);
int nfp_nsp_device_soft_reset(struct nfp_nsp *state); int nfp_nsp_device_soft_reset(struct nfp_nsp *state);
int nfp_nsp_load_fw(struct nfp_nsp *state, const struct firmware *fw); int nfp_nsp_load_fw(struct nfp_nsp *state, const struct firmware *fw);
......
...@@ -182,6 +182,16 @@ void nfp_nsp_close(struct nfp_nsp *state) ...@@ -182,6 +182,16 @@ void nfp_nsp_close(struct nfp_nsp *state)
kfree(state); kfree(state);
} }
u16 nfp_nsp_get_abi_ver_major(struct nfp_nsp *state)
{
return state->ver.major;
}
u16 nfp_nsp_get_abi_ver_minor(struct nfp_nsp *state)
{
return state->ver.minor;
}
static int static int
nfp_nsp_wait_reg(struct nfp_cpp *cpp, u64 *reg, nfp_nsp_wait_reg(struct nfp_cpp *cpp, u64 *reg,
u32 nsp_cpp, u64 addr, u64 mask, u64 val) u32 nsp_cpp, u64 addr, u64 mask, u64 val)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment