forked from torvalds/linux
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libbpf: add functions to get XSK modes
Add functions to get XDP/XSK modes from netdev feature flags over netlink ethtool family interface. These functions provide functionalities that are going to be used in upcoming changes together constituting new libbpf public API function which informs about key xsk capabilities of given network interface. Signed-off-by: Marek Majtyka <marekx.majtyka@intel.com>
- Loading branch information
1 parent
1962c0a
commit fd9c137
Showing
4 changed files
with
469 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ | ||
|
||
/* | ||
* Generic netlink ethtool family required defines | ||
* | ||
* Copyright (c) 2020 Intel | ||
*/ | ||
|
||
#ifndef __LIBBPF_ETHTOOL_H_ | ||
#define __LIBBPF_ETHTOOL_H_ | ||
|
||
#include <linux/ethtool_netlink.h> | ||
|
||
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) | ||
#define FEATURE_BITS_TO_BLOCKS(n_bits) DIV_ROUND_UP(n_bits, 32U) | ||
|
||
#define FEATURE_WORD(blocks, index) ((blocks)[(index) / 32U]) | ||
#define FEATURE_FIELD_FLAG(index) (1U << (index) % 32U) | ||
#define FEATURE_BIT_IS_SET(blocks, index) \ | ||
(FEATURE_WORD(blocks, index) & FEATURE_FIELD_FLAG(index)) | ||
|
||
#define NETDEV_XDP_STR "xdp" | ||
#define NETDEV_XDP_LEN 4 | ||
|
||
#define NETDEV_AF_XDP_ZC_STR "af-xdp-zc" | ||
#define NETDEV_AF_XDP_ZC_LEN 10 | ||
|
||
#define BUF_SIZE_4096 4096 | ||
#define BUF_SIZE_8192 8192 | ||
|
||
#define MAX_FEATURES 500 | ||
|
||
struct ethnl_params { | ||
const char *ifname; | ||
const char *nl_family; | ||
int features; | ||
int xdp_idx; | ||
int xdp_zc_idx; | ||
int xdp_flags; | ||
int xdp_zc_flags; | ||
__u16 fam_id; | ||
}; | ||
|
||
int libbpf_ethnl_get_ethtool_family_id(struct ethnl_params *param); | ||
int libbpf_ethnl_get_netdev_features(struct ethnl_params *param); | ||
int libbpf_ethnl_get_active_bits(struct ethnl_params *param); | ||
|
||
#endif /* __LIBBPF_ETHTOOL_H_ */ | ||
|
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
Oops, something went wrong.