net/hsr: Switch from dev_add_pack() to netdev_rx_handler_register()
Subsystems (3)
PATCH 2/10 net/hsr: Switch from dev_add_pack() to netdev_rx_handler_register()
Also move the frame receive handler to hsr_slave.c.
Signed-off-by Arvid Brodin <[email protected]>
--- net/hsr/Makefile | 3 +- net/hsr/hsr_device.c | 13 ++- net/hsr/hsr_main.c | 248 +-------------------------------------------------- net/hsr/hsr_main.h | 3 + net/hsr/hsr_slave.c | 243 +++++++++++++++++++++++++++++++++++++++++++++++++ net/hsr/hsr_slave.h | 20 +++++ 6 files changed, 283 insertions(+), 247 deletions(-) create mode 100644 net/hsr/hsr_slave.c create mode 100644 net/hsr/hsr_slave.h
net/hsr/Makefile +2 -1
@@ -4,4 +4,5 @@ obj-$(CONFIG_HSR) += hsr.o -hsr-y := hsr_main.o hsr_framereg.o hsr_device.o hsr_netlink.o +hsr-y := hsr_main.o hsr_framereg.o hsr_device.o hsr_netlink.o \ + hsr_slave.o
net/hsr/hsr_device.c +12 -1
@@ -19,6 +19,7 @@#include <linux/rtnetlink.h> #include <linux/pkt_sched.h> #include "hsr_device.h" +#include "hsr_slave.h" #include "hsr_framereg.h" #include "hsr_main.h"
@@ -393,7 +394,6 @@ static void restore_slaves(struct net_device *hsr_dev)rtnl_lock (); -/* Restore promiscuity */ for (i =0 ; i <HSR_MAX_SLAVE ; i++) {if (!hsr->slave[i])continue ;
@@ -402,8 +402,12 @@ static void restore_slaves(struct net_device *hsr_dev)netdev_info (hsr_dev,"Cannot restore slave promiscuity (%s, %d)\n" , hsr->slave[i]->name, res); + +if (hsr->slave[i]->rx_handler == hsr_handle_frame) +netdev_rx_handler_unregister (hsr->slave[i]); } +rtnl_unlock (); }
@@ -575,6 +579,13 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], } } +for (i =0 ; i <HSR_MAX_SLAVE ; i++) { + res =netdev_rx_handler_register (slave[i], hsr_handle_frame, + hsr); +if (res) + goto fail; + } +/* Make sure we recognize frames from ourselves in hsr_rcv() */ res =hsr_create_self_node (&hsr->self_node_db, hsr_dev->dev_addr, hsr->slave[1 ]->dev_addr);
net/hsr/hsr_main.c +3 -245
290 lines not on this page · raw message
net/hsr/hsr_main.h +3 -0
@@ -162,5 +162,8 @@ struct hsr_priv {void register_hsr_master (struct hsr_priv *hsr);void unregister_hsr_master (struct hsr_priv *hsr);bool is_hsr_slave (struct net_device *dev); +struct hsr_priv *get_hsr_master (struct net_device *dev); +struct net_device *get_other_slave (struct hsr_priv *hsr, +struct net_device *dev);#endif /* __HSR_PRIVATE_H */
net/hsr/hsr_slave.c new file +243 -0
243 lines not on this page · raw message
net/hsr/hsr_slave.h new file +20 -0
@@ -0,0 +1,20 @@ +/* Copyright 2011-2014 Autronica Fire and Security AS +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the Free +* Software Foundation; either version 2 of the License, or (at your option) +* any later version. +* +* Author(s): +* 2011-2014 Arvid Brodin, [email protected] +*/ + +#ifndef __HSR_SLAVE_H +#define __HSR_SLAVE_H + +#include <linux/skbuff.h> +#include <linux/netdevice.h> + +rx_handler_result_t hsr_handle_frame (struct sk_buff **pskb); + +#endif /* __HSR_SLAVE_H */
Signature · 6 lines
1.8.3.2 -- Arvid Brodin | Consultant (Linux) ALTEN | Knarrarnäsgatan 7 | SE-164 40 Kista | Sweden [email protected] | www.alten.se/en/