Skip to content

Commit 9bdca14

Browse files
solbjorndavem330
authored andcommitted
qede: introduce support for FEC control
Add Ethtool callbacks for querying and setting FEC parameters if it's supported by the underlying qed module and MFW version running on the device. Signed-off-by: Alexander Lobakin <alobakin@marvell.com> Signed-off-by: Igor Russkikh <irusskikh@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4607615 commit 9bdca14

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

‎drivers/net/ethernet/qlogic/qede/qede_ethtool.c‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,6 +1834,78 @@ static int qede_set_eee(struct net_device *dev, struct ethtool_eee *edata)
18341834
return 0;
18351835
}
18361836

1837+
static u32 qede_link_to_ethtool_fec(u32 link_fec)
1838+
{
1839+
u32 eth_fec = 0;
1840+
1841+
if (link_fec & QED_FEC_MODE_NONE)
1842+
eth_fec |= ETHTOOL_FEC_OFF;
1843+
if (link_fec & QED_FEC_MODE_FIRECODE)
1844+
eth_fec |= ETHTOOL_FEC_BASER;
1845+
if (link_fec & QED_FEC_MODE_RS)
1846+
eth_fec |= ETHTOOL_FEC_RS;
1847+
if (link_fec & QED_FEC_MODE_AUTO)
1848+
eth_fec |= ETHTOOL_FEC_AUTO;
1849+
if (link_fec & QED_FEC_MODE_UNSUPPORTED)
1850+
eth_fec |= ETHTOOL_FEC_NONE;
1851+
1852+
return eth_fec;
1853+
}
1854+
1855+
static u32 qede_ethtool_to_link_fec(u32 eth_fec)
1856+
{
1857+
u32 link_fec = 0;
1858+
1859+
if (eth_fec & ETHTOOL_FEC_OFF)
1860+
link_fec |= QED_FEC_MODE_NONE;
1861+
if (eth_fec & ETHTOOL_FEC_BASER)
1862+
link_fec |= QED_FEC_MODE_FIRECODE;
1863+
if (eth_fec & ETHTOOL_FEC_RS)
1864+
link_fec |= QED_FEC_MODE_RS;
1865+
if (eth_fec & ETHTOOL_FEC_AUTO)
1866+
link_fec |= QED_FEC_MODE_AUTO;
1867+
if (eth_fec & ETHTOOL_FEC_NONE)
1868+
link_fec |= QED_FEC_MODE_UNSUPPORTED;
1869+
1870+
return link_fec;
1871+
}
1872+
1873+
static int qede_get_fecparam(struct net_device *dev,
1874+
struct ethtool_fecparam *fecparam)
1875+
{
1876+
struct qede_dev *edev = netdev_priv(dev);
1877+
struct qed_link_output curr_link;
1878+
1879+
memset(&curr_link, 0, sizeof(curr_link));
1880+
edev->ops->common->get_link(edev->cdev, &curr_link);
1881+
1882+
fecparam->active_fec = qede_link_to_ethtool_fec(curr_link.active_fec);
1883+
fecparam->fec = qede_link_to_ethtool_fec(curr_link.sup_fec);
1884+
1885+
return 0;
1886+
}
1887+
1888+
static int qede_set_fecparam(struct net_device *dev,
1889+
struct ethtool_fecparam *fecparam)
1890+
{
1891+
struct qede_dev *edev = netdev_priv(dev);
1892+
struct qed_link_params params;
1893+
1894+
if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
1895+
DP_INFO(edev, "Link settings are not allowed to be changed\n");
1896+
return -EOPNOTSUPP;
1897+
}
1898+
1899+
memset(&params, 0, sizeof(params));
1900+
params.override_flags |= QED_LINK_OVERRIDE_FEC_CONFIG;
1901+
params.fec = qede_ethtool_to_link_fec(fecparam->fec);
1902+
params.link_up = true;
1903+
1904+
edev->ops->common->set_link(edev->cdev, &params);
1905+
1906+
return 0;
1907+
}
1908+
18371909
static int qede_get_module_info(struct net_device *dev,
18381910
struct ethtool_modinfo *modinfo)
18391911
{
@@ -2070,6 +2142,8 @@ static const struct ethtool_ops qede_ethtool_ops = {
20702142
.get_module_eeprom = qede_get_module_eeprom,
20712143
.get_eee = qede_get_eee,
20722144
.set_eee = qede_set_eee,
2145+
.get_fecparam = qede_get_fecparam,
2146+
.set_fecparam = qede_set_fecparam,
20732147
.get_tunable = qede_get_tunable,
20742148
.set_tunable = qede_set_tunable,
20752149
.flash_device = qede_flash_device,

0 commit comments

Comments
 (0)