nfp: ethtool: support reporting link modes
Subsystems (3)
PATCH v2 1/1 nfp: ethtool: support reporting link modes
From: Yu Xiao <[email protected]>
Add support for reporting link modes,
including Supported link modes and Advertised link modes, via ethtool $DEV.
A new command SPCODE_READ_MEDIA is added to read info from management firmware. Also, the mapping table nfp_eth_media_table associates the link modes between NFP and kernel. Both of them help to support this ability.
---
v2
* Replace u8 with u16 for nfp_eth_media_table, as u8 is too easily overflowed
* Add tab alignments for link modes of nfp_eth_media_table, a visual cleanup
* Correct the initialization format of struct nfp_eth_media_buf ethm
* Replace u8 with unsigned int i for loop variable,
there is no need to restrict the width of iterators
* Replace test_bit() with BIT_ULL(), as the second input of test_bit() need unsigned long
* Use __le64 instead of DECLARE_BITMAP() in struct nfp_eth_media_buf, as the former is hardware appropriate while the latter is not
* Use %pe in int nfp_eth_read_media(),
to allow printing symbolic name of error
--- drivers/net/ethernet/netronome/nfp/nfp_main.h | 1 + .../ethernet/netronome/nfp/nfp_net_ethtool.c | 73 +++++++++++++++++++ .../ethernet/netronome/nfp/nfpcore/nfp_nsp.c | 17 +++++ .../ethernet/netronome/nfp/nfpcore/nfp_nsp.h | 56 ++++++++++++++ .../netronome/nfp/nfpcore/nfp_nsp_eth.c | 26 +++++++ 5 files changed, 173 insertions(+)
drivers/net/ethernet/netronome/nfp/nfp_main.h +1 -0
@@ -27,6 +27,7 @@ struct nfp_hwinfo;struct nfp_mip ;struct nfp_net ;struct nfp_nsp_identify ; +struct nfp_eth_media_buf ;struct nfp_port ;struct nfp_rtsym ;struct nfp_rtsym_table ;
drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c +73 -0
91 lines not on this page · raw message
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c +17 -0
@@ -100,6 +100,7 @@ enum nfp_nsp_cmd {SPCODE_FW_LOADED =19 ,/* Is application firmware loaded */ SPCODE_VERSIONS =21 ,/* Report FW versions */ SPCODE_READ_SFF_EEPROM =22 ,/* Read module EEPROM */ + SPCODE_READ_MEDIA = 23, /* Get either the supported or advertised media for a port */ }; struct nfp_nsp_dma_buf {
@@ -1100,4 +1101,20 @@ int nfp_nsp_read_module_eeprom(struct nfp_nsp *state, int eth_index,kfree (buf);return ret; +}; + +int nfp_nsp_read_media (struct nfp_nsp *state,void *buf,unsigned int size) +{ +struct nfp_nsp_command_buf_arg media = { + { + .code =SPCODE_READ_MEDIA , + .option = size, + }, + .in_buf = buf, + .in_size = size, + .out_buf = buf, + .out_size = size, + }; + +return nfp_nsp_command_buf (state, &media); }
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h +56 -0
74 lines not on this page · raw message
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c +26 -0
@@ -647,3 +647,29 @@ int __nfp_eth_set_split(struct nfp_nsp *nsp, unsigned int lanes)return NFP_ETH_SET_BIT_CONFIG (nsp,NSP_ETH_RAW_PORT ,NSP_ETH_PORT_LANES , lanes,NSP_ETH_CTRL_SET_LANES ); } + +int nfp_eth_read_media (struct nfp_cpp *cpp,struct nfp_eth_media_buf *ethm) +{ +struct nfp_nsp *nsp; +int ret; + + nsp =nfp_nsp_open (cpp); +if (IS_ERR (nsp)) { +nfp_err (cpp,"Failed to access the NSP: %pe\n" , nsp); +return PTR_ERR (nsp); + } + +if (!nfp_nsp_has_read_media (nsp)) { +nfp_warn (cpp,"Reading media link modes not supported. Please update flash\n" ); + ret = -EOPNOTSUPP ; + goto exit_close_nsp; + } + + ret =nfp_nsp_read_media (nsp, ethm,sizeof (*ethm)); +if (ret) +nfp_err (cpp,"Reading media link modes failed: %pe\n" ,ERR_PTR (ret)); + +exit_close_nsp: +nfp_nsp_close (nsp); +return ret; +}
Signature · 1 line
2.30.2
From: Simon Horman <[email protected]>
Date: Fri, 25 Nov 2022 12:30:30 +0100
Quoted 14 lines
From: Yu Xiao <[email protected]>
Add support for reporting link modes,
includingSupported link modesandAdvertised link modes, via ethtool $DEV.A new command
SPCODE_READ_MEDIAis added to read info from management firmware. Also, the mapping tablenfp_eth_media_tableassociates the link modes between NFP and kernel. Both of them help to support this ability.Signed-off-by Yu Xiao <[email protected]>Reviewed-by Louis Peens <[email protected]>Signed-off-by Simon Horman <[email protected]>
[...]
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c int nfp_nsp_read_module_eeprom(struct nfp_nsp *state, int eth_index, · line 1112
Quoted 13 lines
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c +9
-0@@ -1100,4 +1101,20 @@ int nfp_nsp_read_module_eeprom(struct nfp_nsp *state, int eth_index,kfree (buf);return ret; +}; + +int nfp_nsp_read_media (struct nfp_nsp *state,void *buf,unsigned int size) +{ +struct nfp_nsp_command_buf_arg media = { + { + .code =SPCODE_READ_MEDIA , + .option = size, + },
One minor here: the initializers below are designated, but the one above is anonymous, there should be
.arg = {
.code = ...
.option = ...
},ideally.
Up to you whether to send a new rev or leave it as it is, from me:
(please pick it up manually if you send a new rev)
Quoted 8 lines
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c +7
-0+ .in_buf = buf, + .in_size = size, + .out_buf = buf, + .out_size = size, + }; + +return nfp_nsp_command_buf (state, &media); }
[...]
Quoted 2 lines
Signature · 1 line
2.30.2
Thanks,
Olek
On Fri, 25 Nov 2022 15:01:50 +0100, Alexander Lobakin wrote:
<...>
Quoted 11 lines
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c int nfp_nsp_read_module_eeprom(struct nfp_nsp *state, int eth_index, · line 1112
Quoted 7 lines
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c +7
-0+int nfp_nsp_read_media (struct nfp_nsp *state,void *buf,unsigned int size) +{ +struct nfp_nsp_command_buf_arg media = { + { + .code =SPCODE_READ_MEDIA , + .option = size, + },One minor here: the initializers below are designated, but the one above is anonymous, there should be
Quoted 6 lines
.arg = { .code = ... .option = ... },ideally.
Make sense, but we'll leave it as it is to keep it consistent with the other similar functions in this file for now if you don't feel strongly about it. Thanks anyway to point it out.
Quoted 8 lines
Up to you whether to send a new rev or leave it as it is, from me:
Reviewed-by Alexander Lobakin <[email protected]>(please pick it up manually if you send a new rev)
Quoted 2 lines
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c +2
-0+ .in_buf = buf, + .in_size = size,
This patch was applied to bpf/bpf-next.git (master) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Paolo Abeni <[email protected]>:
Quoted 6 lines · On Fri, 25 Nov 2022 12:30:30 +0100 you wrote:
From: Yu Xiao <[email protected]>
Add support for reporting link modes,
includingSupported link modesandAdvertised link modes, via ethtool $DEV.
Quoted 6 lines
A new command
SPCODE_READ_MEDIAis added to read info from management firmware. Also, the mapping tablenfp_eth_media_tableassociates the link modes between NFP and kernel. Both of them help to support this ability.[...]
Here is the summary with links:
- [net-next,v2] nfp: ethtool: support reporting link modes
https://git.kernel.org/bpf/bpf-next/c/a61474c41e8c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html