diff mbox series

[net-next,2/2] mlxsw: core: Add support for devlink info command

Message ID 20190326134535.3826-3-idosch@mellanox.com
State Superseded
Delegated to: David Miller
Headers show
Series mlxsw: Add support for devlink info command | expand

Commit Message

Ido Schimmel March 26, 2019, 1:46 p.m. UTC
From: Shalom Toledo <shalomt@mellanox.com>

Expose the following ASIC information via devlink info command:
  - Hardware revision
  - Firmware PSID
  - Running firmware version

Standard output example:
  $ devlink dev info pci/0000:03:00.0
  pci/0000:03:00.0:
    versions:
        fixed:
          hw.revision A0
          fw.psid MT_2750110033
        running:
          fw.version 13.1910.622

Pretty JSON example:
  $ devlink -jp dev info pci/0000:03:00.0
  {
      "info": {
          "pci/0000:03:00.0": {
              "versions": {
                  "fixed": {
                      "hw.revision": "A0",
                      "fw.psid": "MT_2750110033"
                  },
                  "running": {
                      "fw.version": "13.1910.622"
                  }
              }
          }
      }
  }

Signed-off-by: Shalom Toledo <shalomt@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core.c | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)

Comments

Jakub Kicinski March 26, 2019, 8:48 p.m. UTC | #1
On Tue, 26 Mar 2019 13:46:26 +0000, Ido Schimmel wrote:
> From: Shalom Toledo <shalomt@mellanox.com>
> 
> Expose the following ASIC information via devlink info command:
>   - Hardware revision
>   - Firmware PSID
>   - Running firmware version
> 
> Standard output example:
>   $ devlink dev info pci/0000:03:00.0
>   pci/0000:03:00.0:
>     versions:
>         fixed:
>           hw.revision A0
>           fw.psid MT_2750110033
>         running:
>           fw.version 13.1910.622
> 
> Pretty JSON example:
>   $ devlink -jp dev info pci/0000:03:00.0
>   {
>       "info": {
>           "pci/0000:03:00.0": {
>               "versions": {
>                   "fixed": {
>                       "hw.revision": "A0",
>                       "fw.psid": "MT_2750110033"
>                   },
>                   "running": {
>                       "fw.version": "13.1910.622"
>                   }
>               }
>           }
>       }
>   }
> 
> Signed-off-by: Shalom Toledo <shalomt@mellanox.com>
> Acked-by: Jiri Pirko <jiri@mellanox.com>
> Signed-off-by: Ido Schimmel <idosch@mellanox.com>

Looks good & glad to see it, but what's a PSID? ;)

I found this after 5 seconds of googling:

http://www.mellanox.com/page/firmware_HCA_FW_identification

But it still just say "PSID" without explaining what the acronym stands
for :)
Petr Machata March 27, 2019, 9:47 a.m. UTC | #2
Jakub Kicinski <jakub.kicinski@netronome.com> writes:

> Looks good & glad to see it, but what's a PSID? ;)
>
> I found this after 5 seconds of googling:
>
> http://www.mellanox.com/page/firmware_HCA_FW_identification
>
> But it still just say "PSID" without explaining what the acronym stands
> for :)

"Parameter Set ID"
http://www.mellanox.com/pdf/MFT/MFT_Windows_user_manual.pdf
Jiri Pirko March 27, 2019, 11:08 a.m. UTC | #3
Tue, Mar 26, 2019 at 09:48:07PM CET, jakub.kicinski@netronome.com wrote:
>On Tue, 26 Mar 2019 13:46:26 +0000, Ido Schimmel wrote:
>> From: Shalom Toledo <shalomt@mellanox.com>
>> 
>> Expose the following ASIC information via devlink info command:
>>   - Hardware revision
>>   - Firmware PSID
>>   - Running firmware version
>> 
>> Standard output example:
>>   $ devlink dev info pci/0000:03:00.0
>>   pci/0000:03:00.0:
>>     versions:
>>         fixed:
>>           hw.revision A0
>>           fw.psid MT_2750110033
>>         running:
>>           fw.version 13.1910.622
>> 
>> Pretty JSON example:
>>   $ devlink -jp dev info pci/0000:03:00.0
>>   {
>>       "info": {
>>           "pci/0000:03:00.0": {
>>               "versions": {
>>                   "fixed": {
>>                       "hw.revision": "A0",
>>                       "fw.psid": "MT_2750110033"
>>                   },
>>                   "running": {
>>                       "fw.version": "13.1910.622"
>>                   }
>>               }
>>           }
>>       }
>>   }
>> 
>> Signed-off-by: Shalom Toledo <shalomt@mellanox.com>
>> Acked-by: Jiri Pirko <jiri@mellanox.com>
>> Signed-off-by: Ido Schimmel <idosch@mellanox.com>
>
>Looks good & glad to see it, but what's a PSID? ;)
>
>I found this after 5 seconds of googling:
>
>http://www.mellanox.com/page/firmware_HCA_FW_identification
>
>But it still just say "PSID" without explaining what the acronym stands
>for :)

It's Mellanox board/setup identification.
Jakub Kicinski March 27, 2019, 5:53 p.m. UTC | #4
On Wed, 27 Mar 2019 09:47:14 +0000, Petr Machata wrote:
> Jakub Kicinski <jakub.kicinski@netronome.com> writes:
> 
> > Looks good & glad to see it, but what's a PSID? ;)
> >
> > I found this after 5 seconds of googling:
> >
> > http://www.mellanox.com/page/firmware_HCA_FW_identification
> >
> > But it still just say "PSID" without explaining what the acronym stands
> > for :)  
> 
> "Parameter Set ID"
> http://www.mellanox.com/pdf/MFT/MFT_Windows_user_manual.pdf

Thanks, would it be okay for you guys to spell that out, or at least
add a description to the doc?  Hopefully that can help with reuse and
on the flip side avoiding using the same acronym for completely
different things..
Ido Schimmel March 27, 2019, 7:44 p.m. UTC | #5
On Wed, Mar 27, 2019 at 10:53:37AM -0700, Jakub Kicinski wrote:
> On Wed, 27 Mar 2019 09:47:14 +0000, Petr Machata wrote:
> > Jakub Kicinski <jakub.kicinski@netronome.com> writes:
> > 
> > > Looks good & glad to see it, but what's a PSID? ;)
> > >
> > > I found this after 5 seconds of googling:
> > >
> > > http://www.mellanox.com/page/firmware_HCA_FW_identification
> > >
> > > But it still just say "PSID" without explaining what the acronym stands
> > > for :)  
> > 
> > "Parameter Set ID"
> > http://www.mellanox.com/pdf/MFT/MFT_Windows_user_manual.pdf
> 
> Thanks, would it be okay for you guys to spell that out, or at least
> add a description to the doc?  Hopefully that can help with reuse and
> on the flip side avoiding using the same acronym for completely
> different things..

OK. We can add fw.psid to
Documentation/networking/devlink-info-versions.rst
Jakub Kicinski March 27, 2019, 8:36 p.m. UTC | #6
On Wed, 27 Mar 2019 19:44:11 +0000, Ido Schimmel wrote:
> On Wed, Mar 27, 2019 at 10:53:37AM -0700, Jakub Kicinski wrote:
> > On Wed, 27 Mar 2019 09:47:14 +0000, Petr Machata wrote:  
> > > Jakub Kicinski <jakub.kicinski@netronome.com> writes:
> > >   
> > > > Looks good & glad to see it, but what's a PSID? ;)
> > > >
> > > > I found this after 5 seconds of googling:
> > > >
> > > > http://www.mellanox.com/page/firmware_HCA_FW_identification
> > > >
> > > > But it still just say "PSID" without explaining what the acronym stands
> > > > for :)    
> > > 
> > > "Parameter Set ID"
> > > http://www.mellanox.com/pdf/MFT/MFT_Windows_user_manual.pdf  
> > 
> > Thanks, would it be okay for you guys to spell that out, or at least
> > add a description to the doc?  Hopefully that can help with reuse and
> > on the flip side avoiding using the same acronym for completely
> > different things..  
> 
> OK. We can add fw.psid to
> Documentation/networking/devlink-info-versions.rst

Thanks!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index e70bb673eeec..61ab3fea2376 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -934,6 +934,41 @@  mlxsw_devlink_sb_occ_tc_port_bind_get(struct devlink_port *devlink_port,
 						     pool_type, p_cur, p_max);
 }
 
+static int
+mlxsw_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
+		       struct netlink_ext_ack *extack)
+{
+	struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
+	char fw_info_psid[MLXSW_REG_MGIR_FW_INFO_PSID_SIZE];
+	u32 hw_rev, fw_major, fw_minor, fw_sub_minor;
+	char mgir_pl[MLXSW_REG_MGIR_LEN];
+	char buf[32];
+	int err;
+
+	mlxsw_reg_mgir_pack(mgir_pl);
+	err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mgir), mgir_pl);
+	if (err)
+		return err;
+	mlxsw_reg_mgir_unpack(mgir_pl, &hw_rev, fw_info_psid, &fw_major,
+			      &fw_minor, &fw_sub_minor);
+
+	sprintf(buf, "%X", hw_rev);
+	err = devlink_info_version_fixed_put(req, "hw.revision", buf);
+	if (err)
+		return err;
+
+	err = devlink_info_version_fixed_put(req, "fw.psid", fw_info_psid);
+	if (err)
+		return err;
+
+	sprintf(buf, "%d.%d.%d", fw_major, fw_minor, fw_sub_minor);
+	err = devlink_info_version_running_put(req, "fw.version", buf);
+	if (err)
+		return err;
+
+	return 0;
+}
+
 static int mlxsw_devlink_core_bus_device_reload(struct devlink *devlink,
 						struct netlink_ext_ack *extack)
 {
@@ -968,6 +1003,7 @@  static const struct devlink_ops mlxsw_devlink_ops = {
 	.sb_occ_max_clear		= mlxsw_devlink_sb_occ_max_clear,
 	.sb_occ_port_pool_get		= mlxsw_devlink_sb_occ_port_pool_get,
 	.sb_occ_tc_port_bind_get	= mlxsw_devlink_sb_occ_tc_port_bind_get,
+	.info_get			= mlxsw_devlink_info_get,
 };
 
 static int