liquidio: Add the features to show FEC settings and set FEC settings
Subsystems (3)
PATCH 1/1 liquidio: Add the features to show FEC settings and set FEC settings
From: Weilin Chang <[email protected]>
1. Add functions for get_fecparam and set_fecparam.
2. Modify lio_get_link_ksettings to display FEC setting.
Signed-off-by Weilin Chang <[email protected]>
Acked-by Derek Chickles <[email protected]>
Signed-off-by Felix Manlunas <[email protected]>
--- drivers/net/ethernet/cavium/liquidio/lio_core.c | 148 +++++++++++++++++++++ drivers/net/ethernet/cavium/liquidio/lio_ethtool.c | 76 ++++++++++- drivers/net/ethernet/cavium/liquidio/lio_main.c | 8 ++ .../net/ethernet/cavium/liquidio/liquidio_common.h | 5 + .../net/ethernet/cavium/liquidio/octeon_device.h | 2 + .../net/ethernet/cavium/liquidio/octeon_network.h | 7 +- 6 files changed, 243 insertions(+), 3 deletions(-)
drivers/net/ethernet/cavium/liquidio/lio_core.c +148 -0
@@ -1654,3 +1654,151 @@ int liquidio_get_speed(struct lio *lio)return retval; } + +int liquidio_set_fec (struct lio *lio,int on_off) +{ +struct oct_nic_seapi_resp *resp; +struct octeon_soft_command *sc; +struct octeon_device *oct; +union octnet_cmd *ncmd; +int retval; +u32 var; + + oct = lio->oct_dev; + +if (oct->props[lio->ifidx].fec == on_off) +return 0 ; + +if (!OCTEON_CN23XX_PF (oct)) { +dev_err (&oct->pci_dev->dev,"%s: SET FEC only for PF\n" , + __func__); +return -1 ; + } + +if (oct->speed_boot !=25 ) { +dev_err (&oct->pci_dev->dev, +"Set FEC only when link speed is 25G during insmod\n" ); +return -1 ; + } + + sc =octeon_alloc_soft_command (oct,OCTNET_CMD_SIZE , +sizeof (struct oct_nic_seapi_resp ),0 ); + + ncmd = sc->virtdptr; + resp = sc->virtrptr; +memset (resp,0 ,sizeof (struct oct_nic_seapi_resp )); + +init_completion (&sc->complete); + sc->sc_status =OCTEON_REQUEST_PENDING ; + + ncmd->u64 =0 ; + ncmd->s.cmd =SEAPI_CMD_FEC_SET ; + ncmd->s.param1 = on_off; +/* SEAPI_CMD_FEC_DISABLE(0) or SEAPI_CMD_FEC_RS(1) */ + +octeon_swap_8B_data ((u64 *)ncmd, (OCTNET_CMD_SIZE >>3 )); + + sc->iq_no = lio->linfo.txpciq[0 ].s.q_no; + +octeon_prepare_soft_command (oct, sc,OPCODE_NIC , +OPCODE_NIC_UBOOT_CTL ,0 ,0 ,0 ); + + retval =octeon_send_soft_command (oct, sc); +if (retval ==IQ_SEND_FAILED ) { +dev_info (&oct->pci_dev->dev,"Failed to send soft command\n" ); +octeon_free_soft_command (oct, sc); +return -EIO ; + } + + retval =wait_for_sc_completion_timeout (oct, sc,0 ); +if (retval) +return (-EIO ); + + var =be32_to_cpu (resp->fec_setting); + resp->fec_setting = var; +if (var != on_off) { +dev_err (&oct->pci_dev->dev, +"Setting failed fec= %x, expect %x\n" , + var, on_off); + oct->props[lio->ifidx].fec = var; +if (resp->fec_setting ==SEAPI_CMD_FEC_SET_RS ) + oct->props[lio->ifidx].fec =1 ; +else + oct->props[lio->ifidx].fec =0 ; + } + +WRITE_ONCE (sc->caller_is_done, true); + +if (oct->props[lio->ifidx].fec != + oct->props[lio->ifidx].fec_boot) { +dev_dbg (&oct->pci_dev->dev, +"Reloade driver to chang fec to %s\n" , + oct->props[lio->ifidx].fec ?"on" :"off" ); + } + +return retval; +} + +int liquidio_get_fec (struct lio *lio) +{ +struct oct_nic_seapi_resp *resp; +struct octeon_soft_command *sc; +struct octeon_device *oct; +union octnet_cmd *ncmd; +int retval; +u32 var; + + oct = lio->oct_dev; + + sc =octeon_alloc_soft_command (oct,OCTNET_CMD_SIZE , +sizeof (struct oct_nic_seapi_resp ),0 ); +if (!sc) +return -ENOMEM ; + + ncmd = sc->virtdptr; + resp = sc->virtrptr; +memset (resp,0 ,sizeof (struct oct_nic_seapi_resp )); + +init_completion (&sc->complete); + sc->sc_status =OCTEON_REQUEST_PENDING ; + + ncmd->u64 =0 ; + ncmd->s.cmd =SEAPI_CMD_FEC_GET ; + +octeon_swap_8B_data ((u64 *)ncmd, (OCTNET_CMD_SIZE >>3 )); + + sc->iq_no = lio->linfo.txpciq[0 ].s.q_no; + +octeon_prepare_soft_command (oct, sc,OPCODE_NIC , +OPCODE_NIC_UBOOT_CTL ,0 ,0 ,0 ); + + retval =octeon_send_soft_command (oct, sc); +if (retval ==IQ_SEND_FAILED ) { +dev_info (&oct->pci_dev->dev, +"%s: Failed to send soft command\n" , __func__); +octeon_free_soft_command (oct, sc); +return -EIO ; + } + + retval =wait_for_sc_completion_timeout (oct, sc,0 ); +if (retval) +return retval; + + var =be32_to_cpu (resp->fec_setting); + resp->fec_setting = var; +if (resp->fec_setting ==SEAPI_CMD_FEC_SET_RS ) + oct->props[lio->ifidx].fec =1 ; +else + oct->props[lio->ifidx].fec =0 ; + +WRITE_ONCE (sc->caller_is_done, true); + +if (oct->props[lio->ifidx].fec != + oct->props[lio->ifidx].fec_boot) { +dev_dbg (&oct->pci_dev->dev, +"Reloade driver to chang fec to %s\n" , + oct->props[lio->ifidx].fec ?"on" :"off" ); + } + +return retval; +}
drivers/net/ethernet/cavium/liquidio/lio_ethtool.c +74 -2
105 lines not on this page · raw message
drivers/net/ethernet/cavium/liquidio/lio_main.c +8 -0
@@ -3761,6 +3761,14 @@ static int setup_nic_devices(struct octeon_device *octeon_dev) octeon_dev->speed_setting =10 ; } octeon_dev->speed_boot = octeon_dev->speed_setting; + +/* don't read FEC setting if unsupported by f/w (see above) */ +if (octeon_dev->speed_boot ==25 && + !octeon_dev->no_speed_setting) { +liquidio_get_fec (lio); + octeon_dev->props[lio->ifidx].fec_boot = + octeon_dev->props[lio->ifidx].fec; + } } devlink = devlink_alloc(&liquidio_devlink_ops,
drivers/net/ethernet/cavium/liquidio/liquidio_common.h +5 -0
@@ -260,6 +260,11 @@ static inline void add_sg_size(struct octeon_sg_entry *sg_entry,#define OCTNET_CMD_FAIL 0x1 +#define SEAPI_CMD_FEC_SET 0x0 +#define SEAPI_CMD_FEC_SET_DISABLE 0x0 +#define SEAPI_CMD_FEC_SET_RS 0x1 +#define SEAPI_CMD_FEC_GET 0x1 +#define SEAPI_CMD_SPEED_SET 0x2#define SEAPI_CMD_SPEED_GET 0x3
drivers/net/ethernet/cavium/liquidio/octeon_device.h +2 -0
@@ -316,6 +316,8 @@ struct octdev_props {* device pointer (used for OS specific calls). */ int rx_on; +int fec; +int fec_boot;int napi_enabled;int gmxport;struct net_device *netdev;
drivers/net/ethernet/cavium/liquidio/octeon_network.h +6 -1
@@ -84,7 +84,10 @@ struct oct_nic_stats_ctrl {struct oct_nic_seapi_resp {u64 rh; -u32 speed; +union { +u32 fec_setting; +u32 speed; + };u64 status; };
@@ -236,6 +239,8 @@ int lio_setup_glists(struct octeon_device *oct, struct lio *lio, int num_qs);int liquidio_get_speed (struct lio *lio);int liquidio_set_speed (struct lio *lio,int speed); +int liquidio_get_fec (struct lio *lio); +int liquidio_set_fec (struct lio *lio,int on_off);/** * \brief Net device change_mtu
From: Felix Manlunas <[email protected]>
Date: Sun, 16 Sep 2018 22:43:32 -0700
Quoted 8 lines
From: Weilin Chang <[email protected]>
1. Add functions for
get_fecparamandset_fecparam.
2. Modifylio_get_link_ksettingsto display FEC setting.Signed-off-by Weilin Chang <[email protected]>Acked-by Derek Chickles <[email protected]>Signed-off-by Felix Manlunas <[email protected]>
Applied.