Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XDP support #63

Merged
merged 19 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
modules.order
Module.symvers
compile_commands.json

.vscode/
3 changes: 3 additions & 0 deletions hwmon/xmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,9 @@ struct xocl_xmc {
struct xocl_xmc_privdata *priv_data;
};

int xmc_probe(struct platform_device *pdev);
int xocl_init_xmc(void);
void xocl_fini_xmc(void);

#ifdef XMC_MB
static int load_xmc(struct xocl_xmc *xmc);
Expand Down
2 changes: 1 addition & 1 deletion hwmon/xocl_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
DEFINE_MUTEX(xocl_drvinst_lock);
struct xocl_drvinst *xocl_drvinst_array[XOCL_MAX_DEVICES * 64];

void xocl_drvinst_close(void *data);
void *xocl_drvinst_alloc(struct device *dev, u32 size)
{
struct xocl_drvinst *drvinstp = NULL;
Expand Down
42 changes: 40 additions & 2 deletions onic.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

#include <linux/netdevice.h>
#include <linux/cpumask.h>
#include <linux/bpf.h>
#include <net/xdp.h>
#include <linux/bitops.h>

#include "onic_hardware.h"

Expand All @@ -31,8 +34,24 @@
/* flag bits */
#define ONIC_FLAG_MASTER_PF 0

/* XDP */
#define ONIC_XDP_PASS BIT(0)
#define ONIC_XDP_CONSUMED BIT(1)
#define ONIC_XDP_TX BIT(2)
#define ONIC_XDP_REDIR BIT(3)

enum onic_tx_buf_type {
ONIC_TX_SKB = BIT(0),
ONIC_TX_XDPF = BIT(1),
ONIC_TX_XDPF_XMIT = BIT(2),
};

struct onic_tx_buffer {
struct sk_buff *skb;
enum onic_tx_buf_type type;
union {
struct sk_buff *skb;
struct xdp_frame *xdpf;
};
dma_addr_t dma_addr;
u32 len;
u64 time_stamp;
Expand Down Expand Up @@ -66,6 +85,11 @@ struct onic_tx_queue {
struct onic_tx_buffer *buffer;
struct onic_ring ring;
struct onic_q_vector *vector;

struct {
u64 xdp_xmit;
u64 xdp_xmit_err;
} xdp_tx_stats;
};

struct onic_rx_queue {
Expand All @@ -78,6 +102,18 @@ struct onic_rx_queue {
struct onic_q_vector *vector;

struct napi_struct napi;
struct bpf_prog *xdp_prog;
struct xdp_rxq_info xdp_rxq;
struct page_pool *page_pool;

struct {
u64 xdp_redirect;
u64 xdp_pass;
u64 xdp_drop;
u64 xdp_tx;
u64 xdp_tx_err;
} xdp_rx_stats;

};

struct onic_q_vector {
Expand All @@ -87,6 +123,7 @@ struct onic_q_vector {
int numa_node;
};


/**
* struct onic_private - OpenNIC driver private data
**/
Expand All @@ -104,7 +141,8 @@ struct onic_private {
u16 num_rx_queues;

struct net_device *netdev;
struct rtnl_link_stats64 netdev_stats;
struct bpf_prog *xdp_prog;
struct rtnl_link_stats64 *netdev_stats;
spinlock_t tx_lock;
spinlock_t rx_lock;

Expand Down
1 change: 1 addition & 0 deletions onic_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__

#include <linux/vmalloc.h>
#include "onic_common.h"

void print_raw_data(const u8 *data, u32 len)
Expand Down
Loading
Loading