-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the initial XDP support to the igc driver. For now, only XDP_PASS, XDP_DROP, XDP_ABORTED actions are supported. Upcoming patches will add support for the remaining XDP actions. XDP configuration helpers are defined in a new file, igc_xdp.c. These helpers are utilized in igc_main.c to implement the ndo_bpf callback. XDP-related code that belongs to the driver's hot path is landed in igc_main.c. By default, the driver uses Rx buffers with 2 KB size. When XDP is enabled, it uses larger buffers so we have enough space to accommodate the headroom and tailroom required by XDP infrastructure. Also, the driver doesn't support XDP functionality with frames that span over multiple buffers so jumbo frames are not allowed for now. The approach implemented follows the approach implemented in other Intel drivers as much as possible for the sake of consistency across the drivers. Quick comment regarding igc_build_skb(): this patch doesn't touch it because the function is never called. It seems its support is incomplete/in progress. The function was added by commit 0507ef8 ("igc: Add transmit and receive fastpath and interrupt handlers") but ring_uses_build_skb() always return False since the IGC_RING_FLAG_RX_ BUILD_SKB_ENABLED isn't set anywhere in the driver code. This patch has been tested with the sample app "xdp1" located in samples/bpf/ dir. Signed-off-by: Andre Guedes <andre.guedes@intel.com> Signed-off-by: Vedang Patel <vedang.patel@intel.com> Signed-off-by: Jithu Joseph <jithu.joseph@intel.com> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Tested-by: Dvora Fuxbrumer <dvorax.fuxbrumer@linux.intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
- Loading branch information
Andre Guedes
authored and
Tony Nguyen
committed
Mar 29, 2021
1 parent
1bf33f7
commit 2657510
Showing
5 changed files
with
153 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Copyright (c) 2020, Intel Corporation. */ | ||
|
||
#include "igc.h" | ||
#include "igc_xdp.h" | ||
|
||
int igc_xdp_set_prog(struct igc_adapter *adapter, struct bpf_prog *prog, | ||
struct netlink_ext_ack *extack) | ||
{ | ||
struct net_device *dev = adapter->netdev; | ||
bool if_running = netif_running(dev); | ||
struct bpf_prog *old_prog; | ||
|
||
if (dev->mtu > ETH_DATA_LEN) { | ||
/* For now, the driver doesn't support XDP functionality with | ||
* jumbo frames so we return error. | ||
*/ | ||
NL_SET_ERR_MSG_MOD(extack, "Jumbo frames not supported"); | ||
return -EOPNOTSUPP; | ||
} | ||
|
||
if (if_running) | ||
igc_close(dev); | ||
|
||
old_prog = xchg(&adapter->xdp_prog, prog); | ||
if (old_prog) | ||
bpf_prog_put(old_prog); | ||
|
||
if (if_running) | ||
igc_open(dev); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* Copyright (c) 2020, Intel Corporation. */ | ||
|
||
#ifndef _IGC_XDP_H_ | ||
#define _IGC_XDP_H_ | ||
|
||
int igc_xdp_set_prog(struct igc_adapter *adapter, struct bpf_prog *prog, | ||
struct netlink_ext_ack *extack); | ||
|
||
#endif /* _IGC_XDP_H_ */ |