Commit ccb9bc1d authored by Sixiang Chen's avatar Sixiang Chen Committed by Paolo Abeni

nfp: add 'ethtool --identify' support

Add support for ethtool -p|--identify
by enabling blinking of the panel LED if supported by the NIC firmware.
Signed-off-by: default avatarSixiang Chen <sixiang.chen@corigine.com>
Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/r/20220622083938.291548-1-simon.horman@corigine.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 85763435
......@@ -1477,6 +1477,38 @@ static void nfp_port_get_pauseparam(struct net_device *netdev,
pause->tx_pause = 1;
}
static int nfp_net_set_phys_id(struct net_device *netdev,
enum ethtool_phys_id_state state)
{
struct nfp_eth_table_port *eth_port;
struct nfp_port *port;
int err;
port = nfp_port_from_netdev(netdev);
eth_port = __nfp_port_get_eth_port(port);
if (!eth_port)
return -EOPNOTSUPP;
switch (state) {
case ETHTOOL_ID_ACTIVE:
/* Control LED to blink */
err = nfp_eth_set_idmode(port->app->cpp, eth_port->index, 1);
break;
case ETHTOOL_ID_INACTIVE:
/* Control LED to normal mode */
err = nfp_eth_set_idmode(port->app->cpp, eth_port->index, 0);
break;
case ETHTOOL_ID_ON:
case ETHTOOL_ID_OFF:
default:
return -EOPNOTSUPP;
}
return err;
}
static const struct ethtool_ops nfp_net_ethtool_ops = {
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
ETHTOOL_COALESCE_MAX_FRAMES |
......@@ -1510,6 +1542,7 @@ static const struct ethtool_ops nfp_net_ethtool_ops = {
.get_fecparam = nfp_port_get_fecparam,
.set_fecparam = nfp_port_set_fecparam,
.get_pauseparam = nfp_port_get_pauseparam,
.set_phys_id = nfp_net_set_phys_id,
};
const struct ethtool_ops nfp_port_ethtool_ops = {
......@@ -1528,6 +1561,7 @@ const struct ethtool_ops nfp_port_ethtool_ops = {
.get_fecparam = nfp_port_get_fecparam,
.set_fecparam = nfp_port_set_fecparam,
.get_pauseparam = nfp_port_get_pauseparam,
.set_phys_id = nfp_net_set_phys_id,
};
void nfp_net_set_ethtool_ops(struct net_device *netdev)
......
......@@ -196,6 +196,8 @@ int nfp_eth_set_configured(struct nfp_cpp *cpp, unsigned int idx,
int
nfp_eth_set_fec(struct nfp_cpp *cpp, unsigned int idx, enum nfp_eth_fec mode);
int nfp_eth_set_idmode(struct nfp_cpp *cpp, unsigned int idx, bool state);
static inline bool nfp_eth_can_support_fec(struct nfp_eth_table_port *eth_port)
{
return !!eth_port->fec_modes_supported;
......
......@@ -49,6 +49,7 @@
#define NSP_ETH_CTRL_SET_LANES BIT_ULL(5)
#define NSP_ETH_CTRL_SET_ANEG BIT_ULL(6)
#define NSP_ETH_CTRL_SET_FEC BIT_ULL(7)
#define NSP_ETH_CTRL_SET_IDMODE BIT_ULL(8)
enum nfp_eth_raw {
NSP_ETH_RAW_PORT = 0,
......@@ -492,6 +493,35 @@ nfp_eth_set_bit_config(struct nfp_nsp *nsp, unsigned int raw_idx,
return 0;
}
int nfp_eth_set_idmode(struct nfp_cpp *cpp, unsigned int idx, bool state)
{
union eth_table_entry *entries;
struct nfp_nsp *nsp;
u64 reg;
nsp = nfp_eth_config_start(cpp, idx);
if (IS_ERR(nsp))
return PTR_ERR(nsp);
/* Set this features were added in ABI 0.32 */
if (nfp_nsp_get_abi_ver_minor(nsp) < 32) {
nfp_err(nfp_nsp_cpp(nsp),
"set id mode operation not supported, please update flash\n");
return -EOPNOTSUPP;
}
entries = nfp_nsp_config_entries(nsp);
reg = le64_to_cpu(entries[idx].control);
reg &= ~NSP_ETH_CTRL_SET_IDMODE;
reg |= FIELD_PREP(NSP_ETH_CTRL_SET_IDMODE, state);
entries[idx].control = cpu_to_le64(reg);
nfp_nsp_config_set_modified(nsp, true);
return nfp_eth_config_commit_end(nsp);
}
#define NFP_ETH_SET_BIT_CONFIG(nsp, raw_idx, mask, val, ctrl_bit) \
({ \
__BF_FIELD_CHECK(mask, 0ULL, val, "NFP_ETH_SET_BIT_CONFIG: "); \
......
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