Use of ENOTSUPP in drivers?
Subsystems (11)
Quoted 3 lines · Ben Hutchings
Never return error code ENOTSUPP; it's *not* the same thing as ENOTSUP in userland and is not part of the userland ABI. I would use EINVAL here.
I've found a few ethernet drivers that return -ENOTSUPP in various functions. In particular, some ethtool functions or ioctl's. Ben's message makes me think that the ethtool functions and ioctl's should be modified.
There are other occurences, mostly in functions related to device initialization. I didn't manage to track down exactly from where some of them are called, and I don't know if ENOTSUPP is okay in these.
I've included the complete list of occurences (based on net-next) from drivers/net/ethernet in patch form at the end, if that's more convenient than the file/function list. This is not meant to be applied.
Do these (or part of them) need to be patched? Or is there something I'm missing?
Thanks,
Sabrina
---
* called from ethtool
drivers/net/ethernet/intel/igb/igb_ethtool.c
static int igb_get_sset_count(struct net_device *netdev, int sset)
drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
static int i40evf_get_sset_count(struct net_device *netdev, ...)
drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
static int qlcnic_get_dump_flag(struct net_device *netdev, ...) static int qlcnic_get_dump_data(struct net_device *netdev, ...)
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
/* called via .self_test in struct ethtool_ops */
int qlcnic_83xx_loopback_test(struct net_device *netdev, u8 mode)
drivers/net/ethernet/calxeda/xgmac.c
static int xgmac_set_wol(struct net_device *dev, ...)
* called as ndo_do_ioctl
drivers/net/ethernet/ti/cpsw.c
static int cpsw_ndo_ioctl(struct net_device *dev, ...)
drivers/net/ethernet/marvell/mvneta.c
static int mvneta_ioctl(struct net_device *dev, ...)
drivers/net/ethernet/marvell/mv643xx_eth.c
static int mv643xx_eth_ioctl(struct net_device *dev, ...)
drivers/net/ethernet/freescale/fec_mpc52xx.c
static int mpc52xx_fec_ioctl(struct net_device *dev, ...)
* called as ndo_init
drivers/net/ethernet/lantiq_etop.c
static int ltq_etop_hw_init(struct net_device *dev)
* called from ndo_open (return value ignored)/ not called
drivers/net/ethernet/ti/davinci_cpdma.c
int cpdma_control_get(struct cpdma_ctlr *ctlr, ...) int cpdma_control_set(struct cpdma_ctlr *ctlr, ...)
* not sure, probably fine
drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
/* stored as adapter->ptp_caps.enable, ie struct ptp_clock_info */ static int ixgbe_ptp_enable(struct ptp_clock_info *ptp, ...)
drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
/* called from dcbnl_rtnl_ops.ieee_setets */
static int mlx4_en_ets_validate(struct mlx4_en_priv *priv, ...)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c
/* called from pci_driver.probe in drivers/infiniband/hw/mlx5/main.c */ int mlx5_cmd_init(struct mlx5_core_dev *dev)
drivers/net/ethernet/mellanox/mlx4/mr.c
int mlx4_mw_alloc(struct mlx4_dev *dev, u32 pd, ...)
drivers/net/ethernet/broadcom/bgmac.c
static int bgmac_probe(struct bcma_device *core) /* called by bgmac_probe */
static int bgmac_dma_alloc(struct bgmac *bgmac)
---
ethtool functions
drivers/net/ethernet/calxeda/xgmac.c | 2 +- drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c | 2 +- drivers/net/ethernet/intel/igb/igb_ethtool.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/calxeda/xgmac.c +1 -1
@@ -1677,7 +1677,7 @@ static int xgmac_set_wol(struct net_device *dev,u32 support =WAKE_MAGIC |WAKE_UCAST ;if (!device_can_wakeup (priv->device)) -return -ENOTSUPP ; +return -EINVAL ;if (wol->wolopts & ~support)return -EINVAL ;
drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c +1 -1
@@ -96,7 +96,7 @@ static int i40evf_get_sset_count(struct net_device *netdev, int sset)if (sset ==ETH_SS_STATS )return I40EVF_STATS_LEN ;else -return -ENOTSUPP ; +return -EINVAL ; }/**
drivers/net/ethernet/intel/igb/igb_ethtool.c +1 -1
@@ -2242,7 +2242,7 @@ static int igb_get_sset_count(struct net_device *netdev, int sset)case ETH_SS_TEST :return IGB_TEST_LEN ;default : -return -ENOTSUPP ; +return -EINVAL ; } }
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c +1 -1
@@ -1641,7 +1641,7 @@ int qlcnic_83xx_loopback_test(struct net_device *netdev, u8 mode)if (ahw->op_mode ==QLCNIC_NON_PRIV_FUNC ) {netdev_warn (netdev,"Loopback test not supported in non privileged mode\n" ); -return -ENOTSUPP ; +return -EINVAL ; }if (test_bit (__QLCNIC_RESETTING, &adapter->state)) {
drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +2 -2
@@ -1681,7 +1681,7 @@ qlcnic_get_dump_flag(struct net_device *netdev, struct ethtool_dump *dump)if (!fw_dump->tmpl_hdr) {netdev_err (adapter->netdev,"FW Dump not supported\n" ); -return -ENOTSUPP ; +return -EINVAL ; }if (fw_dump->clr)
@@ -1710,7 +1710,7 @@ qlcnic_get_dump_data(struct net_device *netdev, struct ethtool_dump *dump,if (!fw_dump->tmpl_hdr) {netdev_err (netdev,"FW Dump not supported\n" ); -return -ENOTSUPP ; +return -EINVAL ; }if (!fw_dump->clr) {
---
ndo_do_ioctl functions
drivers/net/ethernet/freescale/fec_mpc52xx.c | 2 +- drivers/net/ethernet/marvell/mv643xx_eth.c | 2 +- drivers/net/ethernet/marvell/mvneta.c | 2 +- drivers/net/ethernet/ti/cpsw.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/freescale/fec_mpc52xx.c +1 -1
@@ -810,7 +810,7 @@ static int mpc52xx_fec_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)struct mpc52xx_fec_priv *priv =netdev_priv (dev);if (!priv->phydev) -return -ENOTSUPP ; +return -EINVAL ;return phy_mii_ioctl (priv->phydev, rq, cmd); }
drivers/net/ethernet/marvell/mv643xx_eth.c +1 -1
@@ -2299,7 +2299,7 @@ static int mv643xx_eth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)int ret;if (mp->phy ==NULL ) -return -ENOTSUPP ; +return -EINVAL ; ret =phy_mii_ioctl (mp->phy, ifr, cmd);if (!ret)
drivers/net/ethernet/marvell/mvneta.c +1 -1
@@ -2490,7 +2490,7 @@ static int mvneta_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)int ret;if (!pp->phy_dev) -return -ENOTSUPP ; +return -EINVAL ; ret =phy_mii_ioctl (pp->phy_dev, ifr, cmd);if (!ret)
drivers/net/ethernet/ti/cpsw.c +1 -1
@@ -1432,7 +1432,7 @@ static int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd) data->phy_id = priv->slaves[slave_no].phy->addr;break ;default : -return -ENOTSUPP ; +return -EINVAL ; }return 0 ;
---
other ndo_* functions
drivers/net/ethernet/lantiq_etop.c | 2 +- drivers/net/ethernet/ti/davinci_cpdma.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/lantiq_etop.c +1 -1
@@ -265,7 +265,7 @@ ltq_etop_hw_init(struct net_device *dev)default :netdev_err (dev,"unknown mii mode %d\n" , priv->pldata->mii_mode); -return -ENOTSUPP ; +return -EINVAL ; }/* enable crc generation */
drivers/net/ethernet/ti/davinci_cpdma.c +2 -2
@@ -993,7 +993,7 @@ int cpdma_control_get(struct cpdma_ctlr *ctlr, int control)spin_lock_irqsave (&ctlr->lock, flags); - ret = -ENOTSUPP ; + ret = -EINVAL ;if (!ctlr->params.has_ext_regs) goto unlock_ret;
@@ -1025,7 +1025,7 @@ int cpdma_control_set(struct cpdma_ctlr *ctlr, int control, int value)spin_lock_irqsave (&ctlr->lock, flags); - ret = -ENOTSUPP ; + ret = -EINVAL ;if (!ctlr->params.has_ext_regs) goto unlock_ret;
---
other functions
drivers/net/ethernet/broadcom/bgmac.c | 10 +++++----- drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c | 2 +- drivers/net/ethernet/mellanox/mlx4/mr.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-)
drivers/net/ethernet/broadcom/bgmac.c +5 -5
@@ -487,7 +487,7 @@ static int bgmac_dma_alloc(struct bgmac *bgmac)if (!(bcma_aread32 (bgmac->core,BCMA_IOST ) &BCMA_IOST_DMA64 )) {bgmac_err (bgmac,"Core does not report 64-bit DMA\n" ); -return -ENOTSUPP ; +return -EINVAL ; }for (i =0 ; i <BGMAC_MAX_TX_RINGS ; i++) {
@@ -1421,7 +1421,7 @@ static int bgmac_probe(struct bcma_device *core)/* We don't support 2nd, 3rd, ... units, SPROM has to be adjusted */ if (core->core_unit >1 ) {pr_err ("Unsupported core_unit %d\n" , core->core_unit); -return -ENOTSUPP ; +return -EINVAL ; }if (!is_valid_ether_addr (mac)) {
@@ -1467,7 +1467,7 @@ static int bgmac_probe(struct bcma_device *core)if (core->bus->hosttype ==BCMA_HOSTTYPE_PCI ) {bgmac_err (bgmac,"PCI setup not implemented\n" ); - err = -ENOTSUPP ; + err = -EINVAL ; goto err_netdev_free; }
@@ -1518,14 +1518,14 @@ static int bgmac_probe(struct bcma_device *core) err =bgmac_mii_register (bgmac);if (err) {bgmac_err (bgmac,"Cannot register MDIO\n" ); - err = -ENOTSUPP ; + err = -EINVAL ; goto err_dma_free; } err =register_netdev (bgmac->net_dev);if (err) {bgmac_err (bgmac,"Cannot register net device\n" ); - err = -ENOTSUPP ; + err = -EINVAL ; goto err_mii_unregister; }
drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c +1 -1
@@ -368,7 +368,7 @@ static int ixgbe_ptp_enable(struct ptp_clock_info *ptp, } } -return -ENOTSUPP ; +return -EINVAL ; }/**
drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c +1 -1
@@ -78,7 +78,7 @@ static int mlx4_en_ets_validate(struct mlx4_en_priv *priv, struct ieee_ets *ets)default :en_err (priv,"TC[%d]: Not supported TSA: %d\n" , i, ets->tc_tsa[i]); -return -ENOTSUPP ; +return -EINVAL ; } }
drivers/net/ethernet/mellanox/mlx4/mr.c +1 -1
@@ -660,7 +660,7 @@ int mlx4_mw_alloc(struct mlx4_dev *dev, u32 pd, enum mlx4_mw_type type, !(dev->caps.flags & MLX4_DEV_CAP_FLAG_MEM_WINDOW)) || (type ==MLX4_MW_TYPE_2 && !(dev->caps.bmme_flags & MLX4_BMME_FLAG_TYPE_2_WIN))) - return -ENOTSUPP; + return -EINVAL; index =mlx4_mpt_reserve (dev);if (index ==-1 )
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +1 -1
@@ -1422,7 +1422,7 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)if (cmd->cmdif_rev >CMD_IF_REV ) {dev_err (&dev->pdev->dev,"driver does not support command interface version. driver %d, firmware %d\n" ,CMD_IF_REV , cmd->cmdif_rev); - err = -ENOTSUPP ; + err = -EINVAL ; goto err_map; }
Quoted 15 lines · Sabrina Dubroca
Quoted 3 lines · Ben Hutchings
Never return error code ENOTSUPP; it's *not* the same thing as ENOTSUP in userland and is not part of the userland ABI. I would use EINVAL here.
I've found a few ethernet drivers that return
-ENOTSUPPin various functions. In particular, some ethtool functions or ioctl's. Ben's message makes me think that the ethtool functions and ioctl's should be modified.There are other occurences, mostly in functions related to device initialization. I didn't manage to track down exactly from where some of them are called, and I don't know if ENOTSUPP is okay in these.
Quoted 8 lines
I've included the complete list of occurences (based on net-next) from
drivers/net/ethernetin patch form at the end, if that's more convenient than the file/function list. This is not meant to be applied.Do these (or part of them) need to be patched? Or is there something I'm missing?
[...]
I believe they should all be patched. According to include/linux/errno.h, ENOTSUPP is meant for use in the NFSv3 code only. (But it's apparently erroneously used *all over* the tree, not just in net drivers!)
Ben.
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Quoted 24 lines · Le dimanche 12 janvier 2014, 20:47:02 Ben Hutchings a écrit :
Quoted 14 lines · Sabrina Dubroca
Quoted 3 lines · Ben Hutchings
Never return error code ENOTSUPP; it's *not* the same thing as ENOTSUP in userland and is not part of the userland ABI. I would use EINVAL here.
I've found a few ethernet drivers that return
-ENOTSUPPin various functions. In particular, some ethtool functions or ioctl's. Ben's message makes me think that the ethtool functions and ioctl's should be modified.There are other occurences, mostly in functions related to device initialization. I didn't manage to track down exactly from where some of them are called, and I don't know if ENOTSUPP is okay in these.
Quoted 8 lines
I've included the complete list of occurences (based on net-next) from
drivers/net/ethernetin patch form at the end, if that's more convenient than the file/function list. This is not meant to be applied.Do these (or part of them) need to be patched? Or is there something I'm missing?
Quoted 6 lines
[...]
I believe they should all be patched. According to
include/linux/errno.h, ENOTSUPP is meant for use in the NFSv3 code only. (But it's apparently erroneously used *all over* the tree, not just in net drivers!)
Most other drivers use -EOPNOTSUPP, which is arguably as bad as -ENOTSUPP, since the comment about it says:
* Operation not supported on transport endpoint *
But at least changing -ENOTSUPP to -EOPNOTSUPP until something better which is not protocol/endpoint specific is agreed on might be better for consistency?
Signature · 1 line
Florian
Quoted 32 lines · Florian Fainelli
Quoted 24 lines · Le dimanche 12 janvier 2014, 20:47:02 Ben Hutchings a écrit :
Quoted 14 lines · Sabrina Dubroca
Quoted 3 lines · Ben Hutchings
Never return error code ENOTSUPP; it's *not* the same thing as ENOTSUP in userland and is not part of the userland ABI. I would use EINVAL here.
I've found a few ethernet drivers that return
-ENOTSUPPin various functions. In particular, some ethtool functions or ioctl's. Ben's message makes me think that the ethtool functions and ioctl's should be modified.There are other occurences, mostly in functions related to device initialization. I didn't manage to track down exactly from where some of them are called, and I don't know if ENOTSUPP is okay in these.
Quoted 8 lines
I've included the complete list of occurences (based on net-next) from
drivers/net/ethernetin patch form at the end, if that's more convenient than the file/function list. This is not meant to be applied.Do these (or part of them) need to be patched? Or is there something I'm missing?
Quoted 6 lines
[...]
I believe they should all be patched. According to
include/linux/errno.h, ENOTSUPP is meant for use in the NFSv3 code only. (But it's apparently erroneously used *all over* the tree, not just in net drivers!)
Quoted 7 lines
Most other drivers use
-EOPNOTSUPP, which is arguably as bad as-ENOTSUPP, since the comment about it says:* Operation not supported on transport endpoint *
But at least changing
-ENOTSUPPto-EOPNOTSUPPuntil something better which is not protocol/endpoint specific is agreed on might be better for consistency?
It is not as bad, because EOPNOTSUPP is actually named in userland (in fact it has two names, the other being ENOTSUP spelt with *one* P).
glibc's strerror() returns these strings for ENOTSUPP and EOPNOTSUPP respectively:
"Unknown error 524"
"Operation not supported"
Ben.
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Quoted 33 lines
-----Original Message-----
From: [email protected] [mailto:netdev- [email protected]] On Behalf Of Sabrina Dubroca
Sent: Monday, January 13, 2014 12:27 AM
To: netdev
Cc: Ben Hutchings
Subject: Use of ENOTSUPP in drivers?Quoted 3 lines · Ben Hutchings
Never return error code ENOTSUPP; it's *not* the same thing as ENOTSUP in userland and is not part of the userland ABI. I would use EINVAL here.
I've found a few ethernet drivers that return
-ENOTSUPPin various functions. In particular, some ethtool functions or ioctl's. Ben's message makes me think that the ethtool functions and ioctl's should be modified.There are other occurences, mostly in functions related to device initialization. I didn't manage to track down exactly from where some of them are called, and I don't know if ENOTSUPP is okay in these.
I've included the complete list of occurences (based on net-next) from
drivers/net/ethernetin patch form at the end, if that's more convenient than the file/function list. This is not meant to be applied.Do these (or part of them) need to be patched? Or is there something I'm missing?
Quoted 6 lines
Thanks,
Sabrina---
Hi Sabrina,
Using -EOPNOTSUPP instead of -ENOTSUPP, ethtool is giving the expected error message.
# ethtool -w p6p1 Can not get dump level : Operation not supported
Quoted 7 lines
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c +0
-0
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c int qlcnic_83xx_loopback_test(struct net_device · line 1646
Quoted 7 lines
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c +1
-1@@ -1641,7 +1641,7 @@ int qlcnic_83xx_loopback_test(struct net_device *netdev, u8 mode)if (ahw->op_mode ==QLCNIC_NON_PRIV_FUNC ) {netdev_warn (netdev,"Loopback test not supported in non privileged mode\n"); -return -ENOTSUPP ; +return -EINVAL ;
Please use -EOPNOTSUPP
Quoted 9 lines
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c +0
-0}if (
test_bit(__QLCNIC_RESETTING, &adapter->state)) { diff --gita/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.cb/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
index 45fa6ef..727be4e 100644
drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c qlcnic_get_dump_flag(struct net_device *netdev, · line 1685
Quoted 6 lines
drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +1
-1@@ -1681,7 +1681,7 @@ qlcnic_get_dump_flag(struct net_device *netdev, struct ethtool_dump *dump)if (!fw_dump->tmpl_hdr) {netdev_err (adapter->netdev,"FW Dump not supported\n" ); -return -ENOTSUPP ; +return -EINVAL ;
Please use -EOPNOTSUPP
drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c qlcnic_get_dump_data(struct net_device *netdev, · line 1714
Quoted 10 lines
drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +0
-0}drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +1
-1if (fw_dump->clr)@@ -1710,7 +1710,7 @@ qlcnic_get_dump_data(struct net_device *netdev,struct ethtool_dump *dump, if (!fw_dump->tmpl_hdr) { netdev_err(netdev, "FW Dump not supported\n"); -return -ENOTSUPP ; +return -EINVAL ;
Please use -EOPNOTSUPP
Quoted 4 lines
drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +0
-0}if (!fw_dump->clr) {
Thanks,
Shahed
From: Ben Hutchings
Quoted 4 lines
I believe they should all be patched. According to
include/linux/errno.h, ENOTSUPP is meant for use in the NFSv3 code only. (But it's apparently erroneously used *all over* the tree, not just in net drivers!)
The 'real' problem is that there are quite a few very specific errno values, but very few general ones.
I suspect that once (way back in the 1980s - the definitions predate linux) adding new errno values was easy, and some that might have been general got documented for their single use - the text for EAGAIN used to be "No more processes".
New errno values were added for some subsystems (like NFS) but documented with subsystem-specific texts.
So there are few generic errno codes except EINVAL and ENXIO - neither of which is helpful.
Nothing for thinks like:
- I don't understand the request.
- I don't support the request.
- Some internal limit reached.
etc.
David