batman-adv: Prefix bridge_loop_avoidance non-static functions with batadv_
[deliverable/linux.git] / net / batman-adv / soft-interface.c
index 6e2530b020437e7243ff2a71d6098a11d7d5df52..16e866ad17597df8cd8016ed93560bf96e46fd8f 100644 (file)
@@ -45,6 +45,10 @@ static void bat_get_drvinfo(struct net_device *dev,
 static u32 bat_get_msglevel(struct net_device *dev);
 static void bat_set_msglevel(struct net_device *dev, u32 value);
 static u32 bat_get_link(struct net_device *dev);
+static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data);
+static void batadv_get_ethtool_stats(struct net_device *dev,
+                                    struct ethtool_stats *stats, u64 *data);
+static int batadv_get_sset_count(struct net_device *dev, int stringset);
 
 static const struct ethtool_ops bat_ethtool_ops = {
        .get_settings = bat_get_settings,
@@ -52,6 +56,9 @@ static const struct ethtool_ops bat_ethtool_ops = {
        .get_msglevel = bat_get_msglevel,
        .set_msglevel = bat_set_msglevel,
        .get_link = bat_get_link,
+       .get_strings = batadv_get_strings,
+       .get_ethtool_stats = batadv_get_ethtool_stats,
+       .get_sset_count = batadv_get_sset_count,
 };
 
 int my_skb_head_push(struct sk_buff *skb, unsigned int len)
@@ -155,7 +162,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
                goto dropped;
        }
 
-       if (bla_tx(bat_priv, skb, vid))
+       if (batadv_bla_tx(bat_priv, skb, vid))
                goto dropped;
 
        /* Register the client MAC in the transtable */
@@ -302,7 +309,7 @@ void interface_rx(struct net_device *soft_iface,
        /* Let the bridge loop avoidance check the packet. If will
         * not handle it, we can safely push it up.
         */
-       if (bla_rx(bat_priv, skb, vid))
+       if (batadv_bla_rx(bat_priv, skb, vid))
                goto out;
 
        netif_rx(skb);
@@ -399,15 +406,20 @@ struct net_device *softif_create(const char *name)
        bat_priv->primary_if = NULL;
        bat_priv->num_ifaces = 0;
 
+       bat_priv->bat_counters = __alloc_percpu(sizeof(uint64_t) * BAT_CNT_NUM,
+                                               __alignof__(uint64_t));
+       if (!bat_priv->bat_counters)
+               goto unreg_soft_iface;
+
        ret = bat_algo_select(bat_priv, bat_routing_algo);
        if (ret < 0)
-               goto unreg_soft_iface;
+               goto free_bat_counters;
 
-       ret = sysfs_add_meshif(soft_iface);
+       ret = batadv_sysfs_add_meshif(soft_iface);
        if (ret < 0)
-               goto unreg_soft_iface;
+               goto free_bat_counters;
 
-       ret = debugfs_add_meshif(soft_iface);
+       ret = batadv_debugfs_add_meshif(soft_iface);
        if (ret < 0)
                goto unreg_sysfs;
 
@@ -418,9 +430,11 @@ struct net_device *softif_create(const char *name)
        return soft_iface;
 
 unreg_debugfs:
-       debugfs_del_meshif(soft_iface);
+       batadv_debugfs_del_meshif(soft_iface);
 unreg_sysfs:
-       sysfs_del_meshif(soft_iface);
+       batadv_sysfs_del_meshif(soft_iface);
+free_bat_counters:
+       free_percpu(bat_priv->bat_counters);
 unreg_soft_iface:
        unregister_netdevice(soft_iface);
        return NULL;
@@ -433,8 +447,8 @@ out:
 
 void softif_destroy(struct net_device *soft_iface)
 {
-       debugfs_del_meshif(soft_iface);
-       sysfs_del_meshif(soft_iface);
+       batadv_debugfs_del_meshif(soft_iface);
+       batadv_sysfs_del_meshif(soft_iface);
        mesh_free(soft_iface);
        unregister_netdevice(soft_iface);
 }
@@ -486,3 +500,51 @@ static u32 bat_get_link(struct net_device *dev)
 {
        return 1;
 }
+
+/* Inspired by drivers/net/ethernet/dlink/sundance.c:1702
+ * Declare each description string in struct.name[] to get fixed sized buffer
+ * and compile time checking for strings longer than ETH_GSTRING_LEN.
+ */
+static const struct {
+       const char name[ETH_GSTRING_LEN];
+} bat_counters_strings[] = {
+       { "forward" },
+       { "forward_bytes" },
+       { "mgmt_tx" },
+       { "mgmt_tx_bytes" },
+       { "mgmt_rx" },
+       { "mgmt_rx_bytes" },
+       { "tt_request_tx" },
+       { "tt_request_rx" },
+       { "tt_response_tx" },
+       { "tt_response_rx" },
+       { "tt_roam_adv_tx" },
+       { "tt_roam_adv_rx" },
+};
+
+static void batadv_get_strings(struct net_device *dev, uint32_t stringset,
+                              uint8_t *data)
+{
+       if (stringset == ETH_SS_STATS)
+               memcpy(data, bat_counters_strings,
+                      sizeof(bat_counters_strings));
+}
+
+static void batadv_get_ethtool_stats(struct net_device *dev,
+                                    struct ethtool_stats *stats,
+                                    uint64_t *data)
+{
+       struct bat_priv *bat_priv = netdev_priv(dev);
+       int i;
+
+       for (i = 0; i < BAT_CNT_NUM; i++)
+               data[i] = batadv_sum_counter(bat_priv, i);
+}
+
+static int batadv_get_sset_count(struct net_device *dev, int stringset)
+{
+       if (stringset == ETH_SS_STATS)
+               return BAT_CNT_NUM;
+
+       return -EOPNOTSUPP;
+}
This page took 0.038025 seconds and 5 git commands to generate.