Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • atlas-tdaq-felix/felix-versal-tools/flxnet-drivers
1 result
Show changes
Commits on Source (2)
......@@ -50,8 +50,8 @@ These modules creates a network device on Versal card and host PC. Each FLX-182
## Update
Readme updated on 13-11-2024 by Laura Rientsma <l.rientsma@nikhef.nl>
Original author of the driver is Elena Zhivun, last edited on 05-07-2022
Readme updated on 13-11-2024 by Laura Rientsma <l.rientsma@nikhef.nl>\
Original author of the driver is Elena Zhivun, last edited on 05-07-2022\
For questions, please contact Frans Schreuder <f.schreuder@nikhef.nl>
Biggest changes:
......
......@@ -16,7 +16,6 @@ struct flxnet_peer {
unsigned int reg_recv;
unsigned int reg_status;
unsigned char mac_addr[ETH_ALEN];
unsigned int role;
struct net_device *flxnet;
struct tx_queue tx_queue;
};
......
......@@ -226,6 +226,15 @@ void flxnet_remove_peer(struct flxnet_peer *peer) {
list_del(&peer->peer_entry);
kfree(peer);
mutex_unlock(&peer_mutex);
if (list_empty(&peer_list)) {
// disable RX side when all peers are removed
if (message_level & NETIF_MSG_IFDOWN)
pr_info("flxnet_dev: stop RX thread\n");
wake_up_interruptible(&recv_queue);
kthread_stop(recv_task);
del_timer_sync(&recv_timer);
}
}
static bool tx_queue_is_full(struct flxnet_peer *peer) {
......@@ -971,6 +980,19 @@ struct flxnet_peer * flxnet_add_peer(void* __iomem base_address) {
struct flxnet_peer *peer;
pr_info("flxnet_dev: flxnet_add_peer %lX\n", (long unsigned int)base_address);
if (list_empty(&peer_list)) {
// enable RX side when the first peer is added
if (message_level & NETIF_MSG_IFUP)
pr_info("flxnet_dev: initialize RX thread and timer\n");
recv_task = kthread_create(send_recv_thread, NULL, "flxnet RX thread");
if (IS_ERR(recv_task)) {
pr_err("flxnet_dev: failed to create RX thread in %s\n", __FUNCTION__);
return -1;
}
wake_up_process(recv_task);
mod_timer(&recv_timer, jiffies + msecs_to_jiffies(POLL_PERIOD_MS));
}
mutex_lock(&peer_mutex);
peer = kzalloc(sizeof(struct flxnet_peer), GFP_KERNEL);
if (IS_ERR(peer)) {
......@@ -1015,32 +1037,12 @@ int __init flxnet_dev_init(void) {
init_waitqueue_head(&recv_queue);
timer_setup(&recv_timer, recv_timer_function, 0);
INIT_LIST_HEAD(&peer_list);
// enable RX side
if (message_level & NETIF_MSG_IFUP)
pr_info("flxnet_dev: initialize RX thread and timer\n");
recv_task = kthread_create(send_recv_thread, NULL, "flxnet RX thread");
if (IS_ERR(recv_task)) {
pr_err("flxnet_dev: failed to create RX thread in %s\n", __FUNCTION__);
return -1;
}
wake_up_process(recv_task);
mod_timer(&recv_timer, jiffies + msecs_to_jiffies(POLL_PERIOD_MS));
return 0;
}
void __exit flxnet_dev_exit(void) {
pr_info("flxnet_dev: removing %s driver\n", DRV_NAME);
// disable RX side
if (message_level & NETIF_MSG_IFDOWN)
pr_info("flxnet_dev: stop RX thread\n");
wake_up_interruptible(&recv_queue);
kthread_stop(recv_task);
del_timer_sync(&recv_timer);
mutex_destroy(&peer_mutex);
mutex_destroy(&flxnet_mutex);
}
......