* [PATCH iwl-next 1/1] igc: Allow hot-swapping XDP program
@ 2024-11-18 4:15 Song Yoong Siang
2024-11-18 15:24 ` Maciej Fijalkowski
2024-11-27 8:34 ` [Intel-wired-lan] " Avigail Dahan
0 siblings, 2 replies; 3+ messages in thread
From: Song Yoong Siang @ 2024-11-18 4:15 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, David S . Miller,
Jakub Kicinski, Jesper Dangaard Brouer, John Fastabend,
Tony Nguyen, Przemek Kitszel, Andrew Lunn, Eric Dumazet,
Paolo Abeni, Vinicius Costa Gomes
Cc: intel-wired-lan, netdev, linux-kernel, bpf
Currently, the driver would always close and reopen the network interface
when setting/removing the XDP program, regardless of the presence of XDP
resources. This could cause unnecessary disruptions.
To avoid this, introduces a check to determine if there is a need to
close and reopen the interface, allowing for seamless hot-swapping of
XDP programs.
Signed-off-by: Song Yoong Siang <yoong.siang.song@intel.com>
---
drivers/net/ethernet/intel/igc/igc_xdp.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/igc/igc_xdp.c b/drivers/net/ethernet/intel/igc/igc_xdp.c
index e27af72aada8..869815f48ac1 100644
--- a/drivers/net/ethernet/intel/igc/igc_xdp.c
+++ b/drivers/net/ethernet/intel/igc/igc_xdp.c
@@ -13,6 +13,7 @@ int igc_xdp_set_prog(struct igc_adapter *adapter, struct bpf_prog *prog,
struct net_device *dev = adapter->netdev;
bool if_running = netif_running(dev);
struct bpf_prog *old_prog;
+ bool need_update;
if (dev->mtu > ETH_DATA_LEN) {
/* For now, the driver doesn't support XDP functionality with
@@ -22,7 +23,8 @@ int igc_xdp_set_prog(struct igc_adapter *adapter, struct bpf_prog *prog,
return -EOPNOTSUPP;
}
- if (if_running)
+ need_update = !!adapter->xdp_prog != !!prog;
+ if (if_running && need_update)
igc_close(dev);
old_prog = xchg(&adapter->xdp_prog, prog);
@@ -34,7 +36,7 @@ int igc_xdp_set_prog(struct igc_adapter *adapter, struct bpf_prog *prog,
else
xdp_features_clear_redirect_target(dev);
- if (if_running)
+ if (if_running && need_update)
igc_open(dev);
return 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH iwl-next 1/1] igc: Allow hot-swapping XDP program
2024-11-18 4:15 [PATCH iwl-next 1/1] igc: Allow hot-swapping XDP program Song Yoong Siang
@ 2024-11-18 15:24 ` Maciej Fijalkowski
2024-11-27 8:34 ` [Intel-wired-lan] " Avigail Dahan
1 sibling, 0 replies; 3+ messages in thread
From: Maciej Fijalkowski @ 2024-11-18 15:24 UTC (permalink / raw)
To: Song Yoong Siang
Cc: Alexei Starovoitov, Daniel Borkmann, David S . Miller,
Jakub Kicinski, Jesper Dangaard Brouer, John Fastabend,
Tony Nguyen, Przemek Kitszel, Andrew Lunn, Eric Dumazet,
Paolo Abeni, Vinicius Costa Gomes, intel-wired-lan, netdev,
linux-kernel, bpf
On Mon, Nov 18, 2024 at 12:15:45PM +0800, Song Yoong Siang wrote:
> Currently, the driver would always close and reopen the network interface
> when setting/removing the XDP program, regardless of the presence of XDP
> resources. This could cause unnecessary disruptions.
>
> To avoid this, introduces a check to determine if there is a need to
> close and reopen the interface, allowing for seamless hot-swapping of
> XDP programs.
>
> Signed-off-by: Song Yoong Siang <yoong.siang.song@intel.com>
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
> drivers/net/ethernet/intel/igc/igc_xdp.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/igc/igc_xdp.c b/drivers/net/ethernet/intel/igc/igc_xdp.c
> index e27af72aada8..869815f48ac1 100644
> --- a/drivers/net/ethernet/intel/igc/igc_xdp.c
> +++ b/drivers/net/ethernet/intel/igc/igc_xdp.c
> @@ -13,6 +13,7 @@ int igc_xdp_set_prog(struct igc_adapter *adapter, struct bpf_prog *prog,
> struct net_device *dev = adapter->netdev;
> bool if_running = netif_running(dev);
> struct bpf_prog *old_prog;
> + bool need_update;
>
> if (dev->mtu > ETH_DATA_LEN) {
> /* For now, the driver doesn't support XDP functionality with
> @@ -22,7 +23,8 @@ int igc_xdp_set_prog(struct igc_adapter *adapter, struct bpf_prog *prog,
> return -EOPNOTSUPP;
> }
>
> - if (if_running)
> + need_update = !!adapter->xdp_prog != !!prog;
> + if (if_running && need_update)
> igc_close(dev);
>
> old_prog = xchg(&adapter->xdp_prog, prog);
> @@ -34,7 +36,7 @@ int igc_xdp_set_prog(struct igc_adapter *adapter, struct bpf_prog *prog,
> else
> xdp_features_clear_redirect_target(dev);
>
> - if (if_running)
> + if (if_running && need_update)
> igc_open(dev);
>
> return 0;
> --
> 2.34.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Intel-wired-lan] [PATCH iwl-next 1/1] igc: Allow hot-swapping XDP program
2024-11-18 4:15 [PATCH iwl-next 1/1] igc: Allow hot-swapping XDP program Song Yoong Siang
2024-11-18 15:24 ` Maciej Fijalkowski
@ 2024-11-27 8:34 ` Avigail Dahan
1 sibling, 0 replies; 3+ messages in thread
From: Avigail Dahan @ 2024-11-27 8:34 UTC (permalink / raw)
To: Song Yoong Siang, Alexei Starovoitov, Daniel Borkmann,
David S . Miller, Jakub Kicinski, Jesper Dangaard Brouer,
John Fastabend, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
Eric Dumazet, Paolo Abeni, Vinicius Costa Gomes
Cc: intel-wired-lan, netdev, linux-kernel, bpf
On 18/11/2024 6:15, Song Yoong Siang wrote:
> Currently, the driver would always close and reopen the network interface
> when setting/removing the XDP program, regardless of the presence of XDP
> resources. This could cause unnecessary disruptions.
>
> To avoid this, introduces a check to determine if there is a need to
> close and reopen the interface, allowing for seamless hot-swapping of
> XDP programs.
>
> Signed-off-by: Song Yoong Siang <yoong.siang.song@intel.com>
> Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
> drivers/net/ethernet/intel/igc/igc_xdp.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
Tested-by: Avigail Dahan <avigailx.dahan@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-27 8:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-18 4:15 [PATCH iwl-next 1/1] igc: Allow hot-swapping XDP program Song Yoong Siang
2024-11-18 15:24 ` Maciej Fijalkowski
2024-11-27 8:34 ` [Intel-wired-lan] " Avigail Dahan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).