Skip to content

rust: add initial netdevice support #908

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

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions rust/bindings/bindings_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/irq.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/netfilter_arp.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
Expand Down
37 changes: 37 additions & 0 deletions rust/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/build_bug.h>
#include <linux/clk.h>
#include <linux/errname.h>
#include <linux/etherdevice.h>
#include <linux/fs_parser.h>
#include <linux/gfp.h>
#include <linux/highmem.h>
Expand Down Expand Up @@ -478,6 +479,12 @@ void *rust_helper_dev_get_drvdata(struct device *dev)
}
EXPORT_SYMBOL_GPL(rust_helper_dev_get_drvdata);

void rust_helper_dev_set_drvdata(struct device *dev, void *data)
{
dev_set_drvdata(dev, data);
}
EXPORT_SYMBOL_GPL(rust_helper_dev_set_drvdata);

const char *rust_helper_dev_name(const struct device *dev)
{
return dev_name(dev);
Expand Down Expand Up @@ -655,6 +662,36 @@ int rust_helper_fs_parse(struct fs_context *fc,
}
EXPORT_SYMBOL_GPL(rust_helper_fs_parse);

#ifdef CONFIG_NET
void rust_helper_eth_hw_addr_set(struct net_device *dev, const u8 *addr)
{
eth_hw_addr_set(dev, addr);
}
EXPORT_SYMBOL_GPL(rust_helper_eth_hw_addr_set);

void rust_helper_netif_start_queue(struct net_device *dev)
{
netif_start_queue(dev);
}
EXPORT_SYMBOL_GPL(rust_helper_netif_start_queue);

void rust_helper_netif_stop_queue(struct net_device *dev) {
netif_stop_queue(dev);
}
EXPORT_SYMBOL_GPL(rust_helper_netif_stop_queue);

void rust_helper_netdev_sent_queue(struct net_device *dev, unsigned int bytes) {
return netdev_sent_queue(dev, bytes);
}
EXPORT_SYMBOL_GPL(rust_helper_netdev_sent_queue);

struct sk_buff *rust_helper_netdev_alloc_skb_ip_align(struct net_device *dev,
unsigned int length) {
return netdev_alloc_skb_ip_align(dev, length);
}
EXPORT_SYMBOL_GPL(rust_helper_netdev_alloc_skb_ip_align);
#endif

/*
* We use `bindgen`'s `--size_t-is-usize` option to bind the C `size_t` type
* as the Rust `usize` type, so we can use it in contexts where Rust
Expand Down
Loading