32 #include <linux/slab.h>
33 #include <linux/ethtool.h>
35 #include <linux/if_vlan.h>
49 static int batadv_get_sset_count(
struct net_device *
dev,
int stringset);
51 static const struct ethtool_ops batadv_ethtool_ops = {
52 .get_settings = batadv_get_settings,
53 .get_drvinfo = batadv_get_drvinfo,
54 .get_msglevel = batadv_get_msglevel,
55 .set_msglevel = batadv_set_msglevel,
56 .get_link = batadv_get_link,
57 .get_strings = batadv_get_strings,
58 .get_ethtool_stats = batadv_get_ethtool_stats,
59 .get_sset_count = batadv_get_sset_count,
73 result = skb_cow_head(skb, len);
83 netif_start_queue(dev);
89 netif_stop_queue(dev);
106 static int batadv_interface_set_mac_addr(
struct net_device *
dev,
void *
p)
112 if (!is_valid_ether_addr(addr->
sa_data))
121 "mac address changed",
false);
129 static int batadv_interface_change_mtu(
struct net_device *dev,
int new_mtu)
140 static int batadv_interface_tx(
struct sk_buff *
skb,
144 struct batadv_priv *bat_priv = netdev_priv(soft_iface);
149 static const uint8_t stp_addr[
ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 0x00,
154 bool do_bcast =
false;
184 if (batadv_compare_eth(ethhdr->
h_dest, stp_addr))
187 if (is_multicast_ether_addr(ethhdr->
h_dest)) {
215 primary_if = batadv_primary_if_get_selected(bat_priv);
270 batadv_hardif_free_ref(primary_if);
278 struct batadv_priv *bat_priv = netdev_priv(soft_iface);
279 struct ethhdr *ethhdr;
282 short vid __maybe_unused = -1;
289 if (!pskb_may_pull(skb, hdr_size))
293 skb_reset_mac_header(skb);
295 ethhdr = (
struct ethhdr *)skb_mac_header(skb);
351 .ndo_open = batadv_interface_open,
352 .ndo_stop = batadv_interface_release,
353 .ndo_get_stats = batadv_interface_stats,
354 .ndo_set_mac_address = batadv_interface_set_mac_addr,
355 .ndo_change_mtu = batadv_interface_change_mtu,
356 .ndo_start_xmit = batadv_interface_tx,
360 static void batadv_interface_setup(
struct net_device *dev)
378 eth_hw_addr_random(dev);
382 memset(priv, 0,
sizeof(*priv));
393 batadv_interface_setup);
398 bat_priv = netdev_priv(soft_iface);
405 goto free_soft_iface;
409 pr_err(
"Unable to register the batman interface '%s': %i\n",
411 goto free_bat_counters;
434 #ifdef CONFIG_BATMAN_ADV_BLA
437 bat_priv->
tt.last_changeset =
NULL;
438 bat_priv->
tt.last_changeset_len = 0;
439 bat_priv->
tt.poss_change =
false;
446 goto unreg_soft_iface;
450 goto unreg_soft_iface;
468 unregister_netdevice(soft_iface);
484 unregister_netdevice(soft_iface);
489 if (net_dev->
netdev_ops->ndo_start_xmit == batadv_interface_tx)
500 ethtool_cmd_speed_set(cmd,
SPEED_10);
512 static void batadv_get_drvinfo(
struct net_device *dev,
539 static const struct {
541 } batadv_counters_strings[] = {
555 {
"tt_response_tx" },
556 {
"tt_response_rx" },
557 {
"tt_roam_adv_tx" },
558 {
"tt_roam_adv_rx" },
565 memcpy(data, batadv_counters_strings,
566 sizeof(batadv_counters_strings));
569 static void batadv_get_ethtool_stats(
struct net_device *dev,
577 data[i] = batadv_sum_counter(bat_priv, i);
580 static int batadv_get_sset_count(
struct net_device *dev,
int stringset)