Message ID | 20230109191523.12070-5-gerhard@engleder-embedded.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | tsnep: XDP support | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net-next, async |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/cc_maintainers | success | CCed 6 of 6 maintainers |
netdev/build_clang | success | Errors and warnings before: 0 this patch: 0 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 48 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On Mon, 2023-01-09 at 20:15 +0100, Gerhard Engleder wrote: > Add adapter state with flag for down state. This flag will be used by > the XDP TX path to deny TX if adapter is down. > > Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com> What value is this bit adding? From what I can tell you could probably just use netif_carrier_ok in place of this and actually get better coverage in terms of identifying state in which the Tx queue is able to function. So in your XDP_TX patch you could do that if you really need it. As far as the use in your close function it is redundant since the IFF_UP is only set if ndo_open completes, and ndo_stop is only called if IFF_UP is set. So your down flag would be redundant with !IFF_UP in that case.
On 10.01.23 17:05, Alexander H Duyck wrote: > On Mon, 2023-01-09 at 20:15 +0100, Gerhard Engleder wrote: >> Add adapter state with flag for down state. This flag will be used by >> the XDP TX path to deny TX if adapter is down. >> >> Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com> > > What value is this bit adding? > > From what I can tell you could probably just use netif_carrier_ok in > place of this and actually get better coverage in terms of identifying > state in which the Tx queue is able to function. So in your XDP_TX > patch you could do that if you really need it. TX does not check the link state, because the hardware just drops all packets if there is no link. I would like to keep it like that, because it minimizes special behavior if the link is down. netif_carrier_ok() would include the link state. > As far as the use in your close function it is redundant since the > IFF_UP is only set if ndo_open completes, and ndo_stop is only called > if IFF_UP is set. So your down flag would be redundant with !IFF_UP in > that case. tsnep_netdev_close() is called directly during bpf prog setup (see last commit). If the following tsnep_netdev_open() call fails, then this flag signals that the device is actually down even if IFF_UP is set. So in this case the down flag is not redundant to !IFF_UP. Is this a good enough reason for the flag? Gerhard
diff --git a/drivers/net/ethernet/engleder/tsnep.h b/drivers/net/ethernet/engleder/tsnep.h index f93ba48bac3f..d658413ceb14 100644 --- a/drivers/net/ethernet/engleder/tsnep.h +++ b/drivers/net/ethernet/engleder/tsnep.h @@ -147,6 +147,7 @@ struct tsnep_adapter { bool suppress_preamble; phy_interface_t phy_mode; struct phy_device *phydev; + unsigned long state; int msg_enable; struct platform_device *pdev; diff --git a/drivers/net/ethernet/engleder/tsnep_main.c b/drivers/net/ethernet/engleder/tsnep_main.c index 8c6d6e210494..943de5a09693 100644 --- a/drivers/net/ethernet/engleder/tsnep_main.c +++ b/drivers/net/ethernet/engleder/tsnep_main.c @@ -43,6 +43,10 @@ #define TSNEP_COALESCE_USECS_MAX ((ECM_INT_DELAY_MASK >> ECM_INT_DELAY_SHIFT) * \ ECM_INT_DELAY_BASE_US + ECM_INT_DELAY_BASE_US - 1) +enum { + __TSNEP_DOWN, +}; + static void tsnep_enable_irq(struct tsnep_adapter *adapter, u32 mask) { iowrite32(mask, adapter->addr + ECM_INT_ENABLE); @@ -1138,6 +1142,8 @@ static int tsnep_netdev_open(struct net_device *netdev) tsnep_enable_irq(adapter, adapter->queue[i].irq_mask); } + clear_bit(__TSNEP_DOWN, &adapter->state); + return 0; phy_failed: @@ -1160,6 +1166,8 @@ static int tsnep_netdev_close(struct net_device *netdev) struct tsnep_adapter *adapter = netdev_priv(netdev); int i; + set_bit(__TSNEP_DOWN, &adapter->state); + tsnep_disable_irq(adapter, ECM_INT_LINK); tsnep_phy_close(adapter); @@ -1513,6 +1521,7 @@ static int tsnep_probe(struct platform_device *pdev) adapter->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN | NETIF_MSG_TX_QUEUED; + set_bit(__TSNEP_DOWN, &adapter->state); netdev->min_mtu = ETH_MIN_MTU; netdev->max_mtu = TSNEP_MAX_FRAME_SIZE; @@ -1609,6 +1618,8 @@ static int tsnep_remove(struct platform_device *pdev) { struct tsnep_adapter *adapter = platform_get_drvdata(pdev); + set_bit(__TSNEP_DOWN, &adapter->state); + unregister_netdev(adapter->netdev); tsnep_rxnfc_cleanup(adapter);
Add adapter state with flag for down state. This flag will be used by the XDP TX path to deny TX if adapter is down. Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com> --- drivers/net/ethernet/engleder/tsnep.h | 1 + drivers/net/ethernet/engleder/tsnep_main.c | 11 +++++++++++ 2 files changed, 12 insertions(+)