Skip to contentSkip to conversation

mac80211: move out the non-statistics variable estab_plinks from mesh_stat

PATCH Applied Ashok Nagarajan 4 participants 10 messages Oct 9, 2012 – Oct 19, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mac80211: move out the non-statistics variable estab_plinks from mesh_stat

estab_plinks is not a statistics member. Hence move estab_plinks from struct mesh_stat to struct ieee80211_if_mesh

---
 net/mac80211/debugfs_netdev.c |    2 +-
 net/mac80211/ieee80211_i.h    |    2 +-
 net/mac80211/mesh.c           |    2 +-
 net/mac80211/mesh.h           |    2 +-
 net/mac80211/mesh_plink.c     |    4 ++--
 5 files changed, 6 insertions(+), 6 deletions(-)
net/mac80211/debugfs_netdev.c +1 -1
index 6d5aec9..34f0ca4 100644
@@ -471,7 +471,7 @@ IEEE80211_IF_FILE(dropped_frames_congestion,
 		  u.mesh.mshstats.dropped_frames_congestion, DEC);
 IEEE80211_IF_FILE(dropped_frames_no_route,
 		  u.mesh.mshstats.dropped_frames_no_route, DEC);
-IEEE80211_IF_FILE(estab_plinks, u.mesh.mshstats.estab_plinks, ATOMIC);
+IEEE80211_IF_FILE(estab_plinks, u.mesh.estab_plinks, ATOMIC);
 
 /* Mesh parameters */
 IEEE80211_IF_FILE(dot11MeshMaxRetries,
net/mac80211/ieee80211_i.h +1 -1
index 8c80455..34f3cda 100644
@@ -316,7 +316,6 @@ struct mesh_stats {
 	__u32 dropped_frames_ttl;	/* Not transmitted since mesh_ttl == 0*/
 	__u32 dropped_frames_no_route;	/* Not transmitted, no route found */
 	__u32 dropped_frames_congestion;/* Not forwarded due to congestion */
-	atomic_t estab_plinks;
 };
 
 #define PREQ_Q_F_START		0x1
@@ -599,6 +598,7 @@ struct ieee80211_if_mesh {
 	int preq_queue_len;
 	struct mesh_stats mshstats;
 	struct mesh_config mshcfg;
+	atomic_t estab_plinks;
 	u32 mesh_seqnum;
 	bool accepting_plinks;
 	int num_gates;
net/mac80211/mesh.c +1 -1
index ff0296c..5cc7a91 100644
@@ -264,7 +264,7 @@ mesh_add_meshconf_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
 	/* Authentication Protocol identifier */
 	*pos++ = ifmsh->mesh_auth_id;
 	/* Mesh Formation Info - number of neighbors */
-	neighbors = atomic_read(&ifmsh->mshstats.estab_plinks);
+	neighbors = atomic_read(&ifmsh->estab_plinks);
 	/* Number of neighbor mesh STAs or 15 whichever is smaller */
 	neighbors = (neighbors > 15) ? 15 : neighbors;
 	*pos++ = neighbors << 1;
net/mac80211/mesh.h +1 -1
index 25d0f17..8334e94 100644
@@ -324,7 +324,7 @@ extern int mesh_allocated;
 static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata)
 {
 	return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks -
-	       atomic_read(&sdata->u.mesh.mshstats.estab_plinks);
+	       atomic_read(&sdata->u.mesh.estab_plinks);
 }
 
 static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata)
net/mac80211/mesh_plink.c +2 -2
index 3ab34d8..0f45ac9 100644
@@ -50,14 +50,14 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
 static inline
 u32 mesh_plink_inc_estab_count(struct ieee80211_sub_if_data *sdata)
 {
-	atomic_inc(&sdata->u.mesh.mshstats.estab_plinks);
+	atomic_inc(&sdata->u.mesh.estab_plinks);
 	return mesh_accept_plinks_update(sdata);
 }
 
 static inline
 u32 mesh_plink_dec_estab_count(struct ieee80211_sub_if_data *sdata)
 {
-	atomic_dec(&sdata->u.mesh.mshstats.estab_plinks);
+	atomic_dec(&sdata->u.mesh.estab_plinks);
 	return mesh_accept_plinks_update(sdata);
 }
 
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 2/2 80211: Add nl80211 command to get mesh network statistics

The command NL80211_CMD_GET_MESH_STATS gets the statistical information about the mesh network. Currently, the following statistics are provided:

1. Mesh forwarded multicast frames
2. Mesh forwarded unicast frames
3. Mesh total forwarded frames
4. Dropped frames due to mesh_ttl == 0
5. Dropped frames due to no route found
6. Dropped frames due to congestion

The attibute NL80211_ATTR_MESH_PARAMS enumerates the various mesh statistical parameters. A new call back get_mesh_stats() is added. mesh_stats struct is moved from mac80211/ieee80211_i.h to net/cfg80211.h.

---
 include/linux/nl80211.h    |   40 ++++++++++++++++++++++++
 include/net/cfg80211.h     |   26 ++++++++++++++++
 net/mac80211/cfg.c         |   12 +++++++
 net/mac80211/ieee80211_i.h |    9 -----
 net/wireless/nl80211.c     |   71 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 149 insertions(+), 9 deletions(-)
include/linux/nl80211.h +40 -0
index 7df9b50..1a30195 100644
@@ -578,6 +578,9 @@
  *	station, due to particular reason. %NL80211_ATTR_CONN_FAILED_REASON
  *	is used for this.
  *
+ * @NL80211_CMD_GET_MESH_STATS: Get mesh networking statistics for the
+ *	interface identified by %NL80211_ATTR_IFINDEX
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -726,6 +729,8 @@ enum nl80211_commands {
 
 	NL80211_CMD_CONN_FAILED,
 
+	NL80211_CMD_GET_MESH_STATS,
+
 	/* add new commands above here */
 
 	/* used to define NL80211_CMD_MAX below */
@@ -1530,6 +1535,8 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_CONN_FAILED_REASON,
 
+	NL80211_ATTR_MESH_STATS,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
@@ -2188,6 +2195,39 @@ enum nl80211_mntr_flags {
 };
 
 /**
+ * enum nl80211_mesh_stats - mesh statisitics
+ *
+ * Provide statistical information about mesh.
+ *
+ * @__NL80211_MESH_STATS_INVALID: internal use
+ * @NL80211_MESH_STATS_FWDED_MCAST: specifies the number of mesh forwarded
+ *	multicast frames
+ * @NL80211_MESH_STATS_FWDED_UNICAST: specifies the number of mesh forwarded
+ *	unicast frames
+ * @NL80211_MESH_STATS_FWDED_FRAMES: specifies the total number of mesh
+ *	forwarded frames
+ * @NL80211_MESH_STATS_DROPPED_FRAMES_TTL: specifies the number of mesh frames
+ *	dropped since mesh_ttl == 0
+ * @NL80211_MESH_STATS_DROPPED_FRAMES_NO_ROUTE: specifies the number of mesh
+ *	frames dropped due to no route found
+ * @NL80211_MESH_STATS_DROPPED_FRAMES_CONGESTION: specifies the number of mesh
+ *	frames dropped due to congestion
+ */
+enum nl80211_mesh_stats {
+	__NL80211_MESH_STATS_INVALID,
+	NL80211_MESH_STATS_FWDED_MCAST,
+	NL80211_MESH_STATS_FWDED_UNICAST,
+	NL80211_MESH_STATS_FWDED_FRAMES,
+	NL80211_MESH_STATS_DROPPED_FRAMES_TTL,
+	NL80211_MESH_STATS_DROPPED_FRAMES_NO_ROUTE,
+	NL80211_MESH_STATS_DROPPED_FRAMES_CONGESTION,
+
+	/* keep last */
+	__NL80211_MESH_STATS_ATTR_AFTER_LAST,
+	NL80211_MESH_STATS_ATTR_MAX = __NL80211_MESH_STATS_ATTR_AFTER_LAST - 1
+};
+
+/**
  * enum nl80211_meshconf_params - mesh configuration parameters
  *
  * Mesh configuration parameters. These can be changed while the mesh is
include/net/cfg80211.h +26 -0
index ab78b53..1926502 100644
@@ -815,6 +815,27 @@ struct bss_parameters {
 };
 
 /**
+ * struct mesh_stats - 802.11s mesh statistics
+ *
+ * Used to provide statistical information about mesh
+ *
+ * @fwded_mcast: Mesh forwarded multicast frames
+ * @fwded_unicast: Mesh forwarded unicast frames
+ * @fwded_frames: Mesh total forwarded frames
+ * @dropped_frames_ttl: Not transmitted since mesh_ttl == 0
+ * @dropped_frames_no_route: Not transmitted, no route found
+ * @dropped_frames_congestion: Not forwarded due to congestion
+ */
+struct mesh_stats {
+	u32 fwded_mcast;
+	u32 fwded_unicast;
+	u32 fwded_frames;
+	u32 dropped_frames_ttl;
+	u32 dropped_frames_no_route;
+	u32 dropped_frames_congestion;
+};
+
+/**
  * struct mesh_config - 802.11s mesh configuration
  *
  * These parameters can be changed while the mesh is active.
@@ -1492,6 +1513,8 @@ struct cfg80211_gtk_rekey_data {
  *
  * @get_mesh_config: Get the current mesh configuration
  *
+ * @get_mesh_stats: Get the current mesh statistics
+ *
  * @update_mesh_config: Update mesh parameters on a running mesh.
  *	The mask is a bitfield which tells us which parameters to
  *	set, and which to leave alone.
@@ -1688,6 +1711,9 @@ struct cfg80211_ops {
 	int	(*get_mesh_config)(struct wiphy *wiphy,
 				struct net_device *dev,
 				struct mesh_config *conf);
+	int	(*get_mesh_stats)(struct wiphy *wiphy,
+				  struct net_device *dev,
+				  struct mesh_stats *stats);
 	int	(*update_mesh_config)(struct wiphy *wiphy,
 				      struct net_device *dev, u32 mask,
 				      const struct mesh_config *nconf);
net/mac80211/cfg.c +12 -0
index 05f3a31..5af9260 100644
@@ -1496,6 +1496,17 @@ static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
 	return 0;
 }
 
+static int ieee80211_get_mesh_stats(struct wiphy *wiphy,
+				    struct net_device *dev,
+				    struct mesh_stats *stats)
+{
+	struct ieee80211_sub_if_data *sdata;
+	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+	memcpy(stats, &sdata->u.mesh.mshstats, sizeof(*stats));
+	return 0;
+}
+
 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
 				struct net_device *dev,
 				struct mesh_config *conf)
@@ -3082,6 +3093,7 @@ struct cfg80211_ops mac80211_config_ops = {
 	.get_mpath = ieee80211_get_mpath,
 	.dump_mpath = ieee80211_dump_mpath,
 	.update_mesh_config = ieee80211_update_mesh_config,
+	.get_mesh_stats = ieee80211_get_mesh_stats,
 	.get_mesh_config = ieee80211_get_mesh_config,
 	.join_mesh = ieee80211_join_mesh,
 	.leave_mesh = ieee80211_leave_mesh,
net/mac80211/ieee80211_i.h +0 -9
index 34f3cda..c30be38 100644
@@ -309,15 +309,6 @@ struct ieee80211_if_vlan {
 	struct sta_info __rcu *sta;
 };
 
-struct mesh_stats {
-	__u32 fwded_mcast;		/* Mesh forwarded multicast frames */
-	__u32 fwded_unicast;		/* Mesh forwarded unicast frames */
-	__u32 fwded_frames;		/* Mesh total forwarded frames */
-	__u32 dropped_frames_ttl;	/* Not transmitted since mesh_ttl == 0*/
-	__u32 dropped_frames_no_route;	/* Not transmitted, no route found */
-	__u32 dropped_frames_congestion;/* Not forwarded due to congestion */
-};
-
 #define PREQ_Q_F_START		0x1
 #define PREQ_Q_F_REFRESH	0x2
 struct mesh_preq_queue {
net/wireless/nl80211.c +71 -0

89 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#2 lore raw

Re: [PATCH 2/2] [nl, cfg, mac]80211: Add nl80211 command to get mesh network statistics

Hi, Ashok

Mesh Total Forwarded Frames = Mesh Forwarded Unicast Frame + Mesh Forwarded Multicast Frame

Am I right?

-----
Chun-Yeow

Quoted 299 lines · Ashok Nagarajan

The command NL80211_CMD_GET_MESH_STATS gets the statistical information about the mesh network. Currently, the following statistics are provided:

1. Mesh forwarded multicast frames
2. Mesh forwarded unicast frames
3. Mesh total forwarded frames
4. Dropped frames due to mesh_ttl == 0
5. Dropped frames due to no route found
6. Dropped frames due to congestion

The attibute NL80211_ATTR_MESH_PARAMS enumerates the various mesh statistical parameters. A new call back get_mesh_stats() is added. mesh_stats struct is moved from mac80211/ieee80211_i.h to net/cfg80211.h.

---
 include/linux/nl80211.h    |   40 ++++++++++++++++++++++++
 include/net/cfg80211.h     |   26 ++++++++++++++++
 net/mac80211/cfg.c         |   12 +++++++
 net/mac80211/ieee80211_i.h |    9 -----
 net/wireless/nl80211.c     |   71 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 149 insertions(+), 9 deletions(-)
include/linux/nl80211.h +40 -0
index 7df9b50..1a30195 100644
@@ -578,6 +578,9 @@
  *     station, due to particular reason. %NL80211_ATTR_CONN_FAILED_REASON
  *     is used for this.
  *
+ * @NL80211_CMD_GET_MESH_STATS: Get mesh networking statistics for the
+ *     interface identified by %NL80211_ATTR_IFINDEX
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -726,6 +729,8 @@ enum nl80211_commands {
 
        NL80211_CMD_CONN_FAILED,
 
+       NL80211_CMD_GET_MESH_STATS,
+
        /* add new commands above here */
 
        /* used to define NL80211_CMD_MAX below */
@@ -1530,6 +1535,8 @@ enum nl80211_attrs {
 
        NL80211_ATTR_CONN_FAILED_REASON,
 
+       NL80211_ATTR_MESH_STATS,
+
        /* add attributes here, update the policy in nl80211.c */
 
        __NL80211_ATTR_AFTER_LAST,
@@ -2188,6 +2195,39 @@ enum nl80211_mntr_flags {
 };
 
 /**
+ * enum nl80211_mesh_stats - mesh statisitics
+ *
+ * Provide statistical information about mesh.
+ *
+ * @__NL80211_MESH_STATS_INVALID: internal use
+ * @NL80211_MESH_STATS_FWDED_MCAST: specifies the number of mesh forwarded
+ *     multicast frames
+ * @NL80211_MESH_STATS_FWDED_UNICAST: specifies the number of mesh forwarded
+ *     unicast frames
+ * @NL80211_MESH_STATS_FWDED_FRAMES: specifies the total number of mesh
+ *     forwarded frames
+ * @NL80211_MESH_STATS_DROPPED_FRAMES_TTL: specifies the number of mesh frames
+ *     dropped since mesh_ttl == 0
+ * @NL80211_MESH_STATS_DROPPED_FRAMES_NO_ROUTE: specifies the number of mesh
+ *     frames dropped due to no route found
+ * @NL80211_MESH_STATS_DROPPED_FRAMES_CONGESTION: specifies the number of mesh
+ *     frames dropped due to congestion
+ */
+enum nl80211_mesh_stats {
+       __NL80211_MESH_STATS_INVALID,
+       NL80211_MESH_STATS_FWDED_MCAST,
+       NL80211_MESH_STATS_FWDED_UNICAST,
+       NL80211_MESH_STATS_FWDED_FRAMES,
+       NL80211_MESH_STATS_DROPPED_FRAMES_TTL,
+       NL80211_MESH_STATS_DROPPED_FRAMES_NO_ROUTE,
+       NL80211_MESH_STATS_DROPPED_FRAMES_CONGESTION,
+
+       /* keep last */
+       __NL80211_MESH_STATS_ATTR_AFTER_LAST,
+       NL80211_MESH_STATS_ATTR_MAX = __NL80211_MESH_STATS_ATTR_AFTER_LAST - 1
+};
+
+/**
  * enum nl80211_meshconf_params - mesh configuration parameters
  *
  * Mesh configuration parameters. These can be changed while the mesh is
include/net/cfg80211.h +26 -0
index ab78b53..1926502 100644
@@ -815,6 +815,27 @@ struct bss_parameters {
 };
 
 /**
+ * struct mesh_stats - 802.11s mesh statistics
+ *
+ * Used to provide statistical information about mesh
+ *
+ * @fwded_mcast: Mesh forwarded multicast frames
+ * @fwded_unicast: Mesh forwarded unicast frames
+ * @fwded_frames: Mesh total forwarded frames
+ * @dropped_frames_ttl: Not transmitted since mesh_ttl == 0
+ * @dropped_frames_no_route: Not transmitted, no route found
+ * @dropped_frames_congestion: Not forwarded due to congestion
+ */
+struct mesh_stats {
+       u32 fwded_mcast;
+       u32 fwded_unicast;
+       u32 fwded_frames;
+       u32 dropped_frames_ttl;
+       u32 dropped_frames_no_route;
+       u32 dropped_frames_congestion;
+};
+
+/**
  * struct mesh_config - 802.11s mesh configuration
  *
  * These parameters can be changed while the mesh is active.
@@ -1492,6 +1513,8 @@ struct cfg80211_gtk_rekey_data {
  *
  * @get_mesh_config: Get the current mesh configuration
  *
+ * @get_mesh_stats: Get the current mesh statistics
+ *
  * @update_mesh_config: Update mesh parameters on a running mesh.
  *     The mask is a bitfield which tells us which parameters to
  *     set, and which to leave alone.
@@ -1688,6 +1711,9 @@ struct cfg80211_ops {
        int     (*get_mesh_config)(struct wiphy *wiphy,
                                struct net_device *dev,
                                struct mesh_config *conf);
+       int     (*get_mesh_stats)(struct wiphy *wiphy,
+                                 struct net_device *dev,
+                                 struct mesh_stats *stats);
        int     (*update_mesh_config)(struct wiphy *wiphy,
                                      struct net_device *dev, u32 mask,
                                      const struct mesh_config *nconf);
net/mac80211/cfg.c +12 -0
index 05f3a31..5af9260 100644
@@ -1496,6 +1496,17 @@ static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
        return 0;
 }
 
+static int ieee80211_get_mesh_stats(struct wiphy *wiphy,
+                                   struct net_device *dev,
+                                   struct mesh_stats *stats)
+{
+       struct ieee80211_sub_if_data *sdata;
+       sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+       memcpy(stats, &sdata->u.mesh.mshstats, sizeof(*stats));
+       return 0;
+}
+
 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
                                struct net_device *dev,
                                struct mesh_config *conf)
@@ -3082,6 +3093,7 @@ struct cfg80211_ops mac80211_config_ops = {
        .get_mpath = ieee80211_get_mpath,
        .dump_mpath = ieee80211_dump_mpath,
        .update_mesh_config = ieee80211_update_mesh_config,
+       .get_mesh_stats = ieee80211_get_mesh_stats,
        .get_mesh_config = ieee80211_get_mesh_config,
        .join_mesh = ieee80211_join_mesh,
        .leave_mesh = ieee80211_leave_mesh,
net/mac80211/ieee80211_i.h +0 -9
index 34f3cda..c30be38 100644
@@ -309,15 +309,6 @@ struct ieee80211_if_vlan {
        struct sta_info __rcu *sta;
 };
 
-struct mesh_stats {
-       __u32 fwded_mcast;              /* Mesh forwarded multicast frames */
-       __u32 fwded_unicast;            /* Mesh forwarded unicast frames */
-       __u32 fwded_frames;             /* Mesh total forwarded frames */
-       __u32 dropped_frames_ttl;       /* Not transmitted since mesh_ttl == 0*/
-       __u32 dropped_frames_no_route;  /* Not transmitted, no route found */
-       __u32 dropped_frames_congestion;/* Not forwarded due to congestion */
-};
-
 #define PREQ_Q_F_START         0x1
 #define PREQ_Q_F_REFRESH       0x2
 struct mesh_preq_queue {
net/wireless/nl80211.c +71 -1
index f1047ae..279a106 100644
@@ -275,6 +275,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
                                           .len = NL80211_MAX_SUPP_RATES },
        [NL80211_ATTR_BSS_HT_OPMODE] = { .type = NLA_U16 },
 
+       [NL80211_ATTR_MESH_STATS] = { .type = NLA_NESTED },
        [NL80211_ATTR_MESH_CONFIG] = { .type = NLA_NESTED },
        [NL80211_ATTR_SUPPORT_MESH_AUTH] = { .type = NLA_FLAG },
 
@@ -3645,6 +3646,68 @@ static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info)
        return r;
 }
 
+static int nl80211_get_mesh_stats(struct sk_buff *skb,
+                                 struct genl_info *info)
+{
+       struct cfg80211_registered_device *rdev = info->user_ptr[0];
+       struct net_device *dev = info->user_ptr[1];
+       struct wireless_dev *wdev = dev->ieee80211_ptr;
+       struct mesh_stats cur_stats;
+       int err = 0;
+       void *hdr;
+       struct nlattr *pinfoattr;
+       struct sk_buff *msg;
+
+       if (wdev->iftype != NL80211_IFTYPE_MESH_POINT)
+               return -EOPNOTSUPP;
+
+       if (!rdev->ops->get_mesh_stats)
+               return -EOPNOTSUPP;
+
+       wdev_lock(wdev);
+
+       err = rdev->ops->get_mesh_stats(&rdev->wiphy, dev, &cur_stats);
+       wdev_unlock(wdev);
+
+       if (err)
+               return err;
+
+       /* Draw up a netlink message to send back */
+       msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+       if (!msg)
+               return -ENOMEM;
+       hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
+                            NL80211_CMD_GET_MESH_STATS);
+       if (!hdr)
+               goto out;
+       pinfoattr = nla_nest_start(msg, NL80211_ATTR_MESH_STATS);
+       if (!pinfoattr)
+               goto nla_put_failure;
+       if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_FWDED_MCAST,
+                       cur_stats.fwded_mcast) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_FWDED_UNICAST,
+                       cur_stats.fwded_unicast) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_FWDED_FRAMES,
+                       cur_stats.fwded_frames) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_DROPPED_FRAMES_TTL,
+                       cur_stats.dropped_frames_ttl) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_DROPPED_FRAMES_NO_ROUTE,
+                       cur_stats.dropped_frames_no_route) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_DROPPED_FRAMES_CONGESTION,
+                       cur_stats.dropped_frames_congestion))
+               goto nla_put_failure;
+       nla_nest_end(msg, pinfoattr);
+       genlmsg_end(msg, hdr);
+       return genlmsg_reply(msg, info);
+
+ nla_put_failure:
+       genlmsg_cancel(msg, hdr);
+ out:
+       nlmsg_free(msg);
+       return -ENOBUFS;
+}
+
 static int nl80211_get_mesh_config(struct sk_buff *skb,
                                   struct genl_info *info)
 {
@@ -7202,6 +7265,14 @@ static struct genl_ops nl80211_ops[] = {
                .flags = GENL_ADMIN_PERM,
        },
        {
+               .cmd = NL80211_CMD_GET_MESH_STATS,
+               .doit = nl80211_get_mesh_stats,
+               .policy = nl80211_policy,
+               /* can be retrieved by unprivileged users */
+               .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
+                                 NL80211_FLAG_NEED_RTNL,
+       },
+       {
                .cmd = NL80211_CMD_GET_MESH_CONFIG,
                .doit = nl80211_get_mesh_config,
                .policy = nl80211_policy,
--

1.7.5.4

_______________________________________________
Devel mailing list
[email protected]
http://lists.open80211s.org/cgi-bin/mailman/listinfo/devel

#3 lore raw

Re: [PATCH 2/2] [nl, cfg, mac]80211: Add nl80211 command to get mesh network statistics

Hello Yeoh,

Quoted 7 lines · Yeoh Chun-Yeow

Hi, Ashok

Mesh Total Forwarded Frames = Mesh Forwarded Unicast Frame + Mesh Forwarded Multicast Frame

Am I right?

Yes, you are correct.

Quoted 307 lines

-----
Chun-Yeow

Quoted 295 lines · Ashok Nagarajan

The command NL80211_CMD_GET_MESH_STATS gets the statistical information about the mesh network. Currently, the following statistics are provided:

1. Mesh forwarded multicast frames
2. Mesh forwarded unicast frames
3. Mesh total forwarded frames
4. Dropped frames due to mesh_ttl == 0
5. Dropped frames due to no route found
6. Dropped frames due to congestion

The attibute NL80211_ATTR_MESH_PARAMS enumerates the various mesh statistical parameters. A new call back get_mesh_stats() is added. mesh_stats struct is moved from mac80211/ieee80211_i.h to net/cfg80211.h.

---
 include/linux/nl80211.h    |   40 ++++++++++++++++++++++++
 include/net/cfg80211.h     |   26 ++++++++++++++++
 net/mac80211/cfg.c         |   12 +++++++
 net/mac80211/ieee80211_i.h |    9 -----
 net/wireless/nl80211.c     |   71 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 149 insertions(+), 9 deletions(-)
include/linux/nl80211.h +40 -0
index 7df9b50..1a30195 100644
@@ -578,6 +578,9 @@
  *     station, due to particular reason. %NL80211_ATTR_CONN_FAILED_REASON
  *     is used for this.
  *
+ * @NL80211_CMD_GET_MESH_STATS: Get mesh networking statistics for the
+ *     interface identified by %NL80211_ATTR_IFINDEX
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -726,6 +729,8 @@ enum nl80211_commands {
 
        NL80211_CMD_CONN_FAILED,
 
+       NL80211_CMD_GET_MESH_STATS,
+
        /* add new commands above here */
 
        /* used to define NL80211_CMD_MAX below */
@@ -1530,6 +1535,8 @@ enum nl80211_attrs {
 
        NL80211_ATTR_CONN_FAILED_REASON,
 
+       NL80211_ATTR_MESH_STATS,
+
        /* add attributes here, update the policy in nl80211.c */
 
        __NL80211_ATTR_AFTER_LAST,
@@ -2188,6 +2195,39 @@ enum nl80211_mntr_flags {
 };
 
 /**
+ * enum nl80211_mesh_stats - mesh statisitics
+ *
+ * Provide statistical information about mesh.
+ *
+ * @__NL80211_MESH_STATS_INVALID: internal use
+ * @NL80211_MESH_STATS_FWDED_MCAST: specifies the number of mesh forwarded
+ *     multicast frames
+ * @NL80211_MESH_STATS_FWDED_UNICAST: specifies the number of mesh forwarded
+ *     unicast frames
+ * @NL80211_MESH_STATS_FWDED_FRAMES: specifies the total number of mesh
+ *     forwarded frames
+ * @NL80211_MESH_STATS_DROPPED_FRAMES_TTL: specifies the number of mesh frames
+ *     dropped since mesh_ttl == 0
+ * @NL80211_MESH_STATS_DROPPED_FRAMES_NO_ROUTE: specifies the number of mesh
+ *     frames dropped due to no route found
+ * @NL80211_MESH_STATS_DROPPED_FRAMES_CONGESTION: specifies the number of mesh
+ *     frames dropped due to congestion
+ */
+enum nl80211_mesh_stats {
+       __NL80211_MESH_STATS_INVALID,
+       NL80211_MESH_STATS_FWDED_MCAST,
+       NL80211_MESH_STATS_FWDED_UNICAST,
+       NL80211_MESH_STATS_FWDED_FRAMES,
+       NL80211_MESH_STATS_DROPPED_FRAMES_TTL,
+       NL80211_MESH_STATS_DROPPED_FRAMES_NO_ROUTE,
+       NL80211_MESH_STATS_DROPPED_FRAMES_CONGESTION,
+
+       /* keep last */
+       __NL80211_MESH_STATS_ATTR_AFTER_LAST,
+       NL80211_MESH_STATS_ATTR_MAX = __NL80211_MESH_STATS_ATTR_AFTER_LAST - 1
+};
+
+/**
  * enum nl80211_meshconf_params - mesh configuration parameters
  *
  * Mesh configuration parameters. These can be changed while the mesh is
include/net/cfg80211.h +26 -0
index ab78b53..1926502 100644
@@ -815,6 +815,27 @@ struct bss_parameters {
 };
 
 /**
+ * struct mesh_stats - 802.11s mesh statistics
+ *
+ * Used to provide statistical information about mesh
+ *
+ * @fwded_mcast: Mesh forwarded multicast frames
+ * @fwded_unicast: Mesh forwarded unicast frames
+ * @fwded_frames: Mesh total forwarded frames
+ * @dropped_frames_ttl: Not transmitted since mesh_ttl == 0
+ * @dropped_frames_no_route: Not transmitted, no route found
+ * @dropped_frames_congestion: Not forwarded due to congestion
+ */
+struct mesh_stats {
+       u32 fwded_mcast;
+       u32 fwded_unicast;
+       u32 fwded_frames;
+       u32 dropped_frames_ttl;
+       u32 dropped_frames_no_route;
+       u32 dropped_frames_congestion;
+};
+
+/**
  * struct mesh_config - 802.11s mesh configuration
  *
  * These parameters can be changed while the mesh is active.
@@ -1492,6 +1513,8 @@ struct cfg80211_gtk_rekey_data {
  *
  * @get_mesh_config: Get the current mesh configuration
  *
+ * @get_mesh_stats: Get the current mesh statistics
+ *
  * @update_mesh_config: Update mesh parameters on a running mesh.
  *     The mask is a bitfield which tells us which parameters to
  *     set, and which to leave alone.
@@ -1688,6 +1711,9 @@ struct cfg80211_ops {
        int     (*get_mesh_config)(struct wiphy *wiphy,
                                struct net_device *dev,
                                struct mesh_config *conf);
+       int     (*get_mesh_stats)(struct wiphy *wiphy,
+                                 struct net_device *dev,
+                                 struct mesh_stats *stats);
        int     (*update_mesh_config)(struct wiphy *wiphy,
                                      struct net_device *dev, u32 mask,
                                      const struct mesh_config *nconf);
net/mac80211/cfg.c +12 -0
index 05f3a31..5af9260 100644
@@ -1496,6 +1496,17 @@ static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
        return 0;
 }
 
+static int ieee80211_get_mesh_stats(struct wiphy *wiphy,
+                                   struct net_device *dev,
+                                   struct mesh_stats *stats)
+{
+       struct ieee80211_sub_if_data *sdata;
+       sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+       memcpy(stats, &sdata->u.mesh.mshstats, sizeof(*stats));
+       return 0;
+}
+
 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
                                struct net_device *dev,
                                struct mesh_config *conf)
@@ -3082,6 +3093,7 @@ struct cfg80211_ops mac80211_config_ops = {
        .get_mpath = ieee80211_get_mpath,
        .dump_mpath = ieee80211_dump_mpath,
        .update_mesh_config = ieee80211_update_mesh_config,
+       .get_mesh_stats = ieee80211_get_mesh_stats,
        .get_mesh_config = ieee80211_get_mesh_config,
        .join_mesh = ieee80211_join_mesh,
        .leave_mesh = ieee80211_leave_mesh,
net/mac80211/ieee80211_i.h +0 -9
index 34f3cda..c30be38 100644
@@ -309,15 +309,6 @@ struct ieee80211_if_vlan {
        struct sta_info __rcu *sta;
 };
 
-struct mesh_stats {
-       __u32 fwded_mcast;              /* Mesh forwarded multicast frames */
-       __u32 fwded_unicast;            /* Mesh forwarded unicast frames */
-       __u32 fwded_frames;             /* Mesh total forwarded frames */
-       __u32 dropped_frames_ttl;       /* Not transmitted since mesh_ttl == 0*/
-       __u32 dropped_frames_no_route;  /* Not transmitted, no route found */
-       __u32 dropped_frames_congestion;/* Not forwarded due to congestion */
-};
-
 #define PREQ_Q_F_START         0x1
 #define PREQ_Q_F_REFRESH       0x2
 struct mesh_preq_queue {
net/wireless/nl80211.c +71 -1
index f1047ae..279a106 100644
@@ -275,6 +275,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
                                           .len = NL80211_MAX_SUPP_RATES },
        [NL80211_ATTR_BSS_HT_OPMODE] = { .type = NLA_U16 },
 
+       [NL80211_ATTR_MESH_STATS] = { .type = NLA_NESTED },
        [NL80211_ATTR_MESH_CONFIG] = { .type = NLA_NESTED },
        [NL80211_ATTR_SUPPORT_MESH_AUTH] = { .type = NLA_FLAG },
 
@@ -3645,6 +3646,68 @@ static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info)
        return r;
 }
 
+static int nl80211_get_mesh_stats(struct sk_buff *skb,
+                                 struct genl_info *info)
+{
+       struct cfg80211_registered_device *rdev = info->user_ptr[0];
+       struct net_device *dev = info->user_ptr[1];
+       struct wireless_dev *wdev = dev->ieee80211_ptr;
+       struct mesh_stats cur_stats;
+       int err = 0;
+       void *hdr;
+       struct nlattr *pinfoattr;
+       struct sk_buff *msg;
+
+       if (wdev->iftype != NL80211_IFTYPE_MESH_POINT)
+               return -EOPNOTSUPP;
+
+       if (!rdev->ops->get_mesh_stats)
+               return -EOPNOTSUPP;
+
+       wdev_lock(wdev);
+
+       err = rdev->ops->get_mesh_stats(&rdev->wiphy, dev, &cur_stats);
+       wdev_unlock(wdev);
+
+       if (err)
+               return err;
+
+       /* Draw up a netlink message to send back */
+       msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+       if (!msg)
+               return -ENOMEM;
+       hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
+                            NL80211_CMD_GET_MESH_STATS);
+       if (!hdr)
+               goto out;
+       pinfoattr = nla_nest_start(msg, NL80211_ATTR_MESH_STATS);
+       if (!pinfoattr)
+               goto nla_put_failure;
+       if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_FWDED_MCAST,
+                       cur_stats.fwded_mcast) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_FWDED_UNICAST,
+                       cur_stats.fwded_unicast) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_FWDED_FRAMES,
+                       cur_stats.fwded_frames) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_DROPPED_FRAMES_TTL,
+                       cur_stats.dropped_frames_ttl) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_DROPPED_FRAMES_NO_ROUTE,
+                       cur_stats.dropped_frames_no_route) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_DROPPED_FRAMES_CONGESTION,
+                       cur_stats.dropped_frames_congestion))
+               goto nla_put_failure;
+       nla_nest_end(msg, pinfoattr);
+       genlmsg_end(msg, hdr);
+       return genlmsg_reply(msg, info);
+
+ nla_put_failure:
+       genlmsg_cancel(msg, hdr);
+ out:
+       nlmsg_free(msg);
+       return -ENOBUFS;
+}
+
 static int nl80211_get_mesh_config(struct sk_buff *skb,
                                   struct genl_info *info)
 {
@@ -7202,6 +7265,14 @@ static struct genl_ops nl80211_ops[] = {
                .flags = GENL_ADMIN_PERM,
        },
        {
+               .cmd = NL80211_CMD_GET_MESH_STATS,
+               .doit = nl80211_get_mesh_stats,
+               .policy = nl80211_policy,
+               /* can be retrieved by unprivileged users */
+               .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
+                                 NL80211_FLAG_NEED_RTNL,
+       },
+       {
                .cmd = NL80211_CMD_GET_MESH_CONFIG,
                .doit = nl80211_get_mesh_config,
                .policy = nl80211_policy,
--

1.7.5.4

Quoted 4 lines

_______________________________________________
Devel mailing list
[email protected]
http://lists.open80211s.org/cgi-bin/mailman/listinfo/devel

_______________________________________________
Devel mailing list
[email protected]
http://lists.open80211s.org/cgi-bin/mailman/listinfo/devel

#4 lore raw

Re: [PATCH 2/2] [nl, cfg, mac]80211: Add nl80211 command to get mesh network statistics

In reply to Yeoh Chun-Yeow

Hi Chun-Yeow,

Quoted 6 lines · Yeoh Chun-Yeow

Hi, Ashok

Mesh Total Forwarded Frames = Mesh Forwarded Unicast Frame + Mesh Forwarded Multicast Frame

Am I right?

Keep in mind that the patch does not modify those stats, just provides a different way to access them from userspace.
These same stats are accessible today via debugfs:

grep -H . /sys/kernel/debug/ieee80211/phy1/netdev\:mesh1/mesh_stats/* | grep fwded /sys/kernel/debug/ieee80211/phy1/netdev:mesh1/mesh_stats/fwded_frames:2039 /sys/kernel/debug/ieee80211/phy1/netdev:mesh1/mesh_stats/fwded_mcast:13 /sys/kernel/debug/ieee80211/phy1/netdev:mesh1/mesh_stats/fwded_unicast:2026

Cheers,

Javier

Quoted 307 lines

-----
Chun-Yeow

Quoted 295 lines · Ashok Nagarajan

The command NL80211_CMD_GET_MESH_STATS gets the statistical information about the mesh network. Currently, the following statistics are provided:

1. Mesh forwarded multicast frames
2. Mesh forwarded unicast frames
3. Mesh total forwarded frames
4. Dropped frames due to mesh_ttl == 0
5. Dropped frames due to no route found
6. Dropped frames due to congestion

The attibute NL80211_ATTR_MESH_PARAMS enumerates the various mesh statistical parameters. A new call back get_mesh_stats() is added. mesh_stats struct is moved from mac80211/ieee80211_i.h to net/cfg80211.h.

---
 include/linux/nl80211.h    |   40 ++++++++++++++++++++++++
 include/net/cfg80211.h     |   26 ++++++++++++++++
 net/mac80211/cfg.c         |   12 +++++++
 net/mac80211/ieee80211_i.h |    9 -----
 net/wireless/nl80211.c     |   71 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 149 insertions(+), 9 deletions(-)
include/linux/nl80211.h +40 -0
index 7df9b50..1a30195 100644
@@ -578,6 +578,9 @@
  *     station, due to particular reason. %NL80211_ATTR_CONN_FAILED_REASON
  *     is used for this.
  *
+ * @NL80211_CMD_GET_MESH_STATS: Get mesh networking statistics for the
+ *     interface identified by %NL80211_ATTR_IFINDEX
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -726,6 +729,8 @@ enum nl80211_commands {
 
        NL80211_CMD_CONN_FAILED,
 
+       NL80211_CMD_GET_MESH_STATS,
+
        /* add new commands above here */
 
        /* used to define NL80211_CMD_MAX below */
@@ -1530,6 +1535,8 @@ enum nl80211_attrs {
 
        NL80211_ATTR_CONN_FAILED_REASON,
 
+       NL80211_ATTR_MESH_STATS,
+
        /* add attributes here, update the policy in nl80211.c */
 
        __NL80211_ATTR_AFTER_LAST,
@@ -2188,6 +2195,39 @@ enum nl80211_mntr_flags {
 };
 
 /**
+ * enum nl80211_mesh_stats - mesh statisitics
+ *
+ * Provide statistical information about mesh.
+ *
+ * @__NL80211_MESH_STATS_INVALID: internal use
+ * @NL80211_MESH_STATS_FWDED_MCAST: specifies the number of mesh forwarded
+ *     multicast frames
+ * @NL80211_MESH_STATS_FWDED_UNICAST: specifies the number of mesh forwarded
+ *     unicast frames
+ * @NL80211_MESH_STATS_FWDED_FRAMES: specifies the total number of mesh
+ *     forwarded frames
+ * @NL80211_MESH_STATS_DROPPED_FRAMES_TTL: specifies the number of mesh frames
+ *     dropped since mesh_ttl == 0
+ * @NL80211_MESH_STATS_DROPPED_FRAMES_NO_ROUTE: specifies the number of mesh
+ *     frames dropped due to no route found
+ * @NL80211_MESH_STATS_DROPPED_FRAMES_CONGESTION: specifies the number of mesh
+ *     frames dropped due to congestion
+ */
+enum nl80211_mesh_stats {
+       __NL80211_MESH_STATS_INVALID,
+       NL80211_MESH_STATS_FWDED_MCAST,
+       NL80211_MESH_STATS_FWDED_UNICAST,
+       NL80211_MESH_STATS_FWDED_FRAMES,
+       NL80211_MESH_STATS_DROPPED_FRAMES_TTL,
+       NL80211_MESH_STATS_DROPPED_FRAMES_NO_ROUTE,
+       NL80211_MESH_STATS_DROPPED_FRAMES_CONGESTION,
+
+       /* keep last */
+       __NL80211_MESH_STATS_ATTR_AFTER_LAST,
+       NL80211_MESH_STATS_ATTR_MAX = __NL80211_MESH_STATS_ATTR_AFTER_LAST - 1
+};
+
+/**
  * enum nl80211_meshconf_params - mesh configuration parameters
  *
  * Mesh configuration parameters. These can be changed while the mesh is
include/net/cfg80211.h +26 -0
index ab78b53..1926502 100644
@@ -815,6 +815,27 @@ struct bss_parameters {
 };
 
 /**
+ * struct mesh_stats - 802.11s mesh statistics
+ *
+ * Used to provide statistical information about mesh
+ *
+ * @fwded_mcast: Mesh forwarded multicast frames
+ * @fwded_unicast: Mesh forwarded unicast frames
+ * @fwded_frames: Mesh total forwarded frames
+ * @dropped_frames_ttl: Not transmitted since mesh_ttl == 0
+ * @dropped_frames_no_route: Not transmitted, no route found
+ * @dropped_frames_congestion: Not forwarded due to congestion
+ */
+struct mesh_stats {
+       u32 fwded_mcast;
+       u32 fwded_unicast;
+       u32 fwded_frames;
+       u32 dropped_frames_ttl;
+       u32 dropped_frames_no_route;
+       u32 dropped_frames_congestion;
+};
+
+/**
  * struct mesh_config - 802.11s mesh configuration
  *
  * These parameters can be changed while the mesh is active.
@@ -1492,6 +1513,8 @@ struct cfg80211_gtk_rekey_data {
  *
  * @get_mesh_config: Get the current mesh configuration
  *
+ * @get_mesh_stats: Get the current mesh statistics
+ *
  * @update_mesh_config: Update mesh parameters on a running mesh.
  *     The mask is a bitfield which tells us which parameters to
  *     set, and which to leave alone.
@@ -1688,6 +1711,9 @@ struct cfg80211_ops {
        int     (*get_mesh_config)(struct wiphy *wiphy,
                                struct net_device *dev,
                                struct mesh_config *conf);
+       int     (*get_mesh_stats)(struct wiphy *wiphy,
+                                 struct net_device *dev,
+                                 struct mesh_stats *stats);
        int     (*update_mesh_config)(struct wiphy *wiphy,
                                      struct net_device *dev, u32 mask,
                                      const struct mesh_config *nconf);
net/mac80211/cfg.c +12 -0
index 05f3a31..5af9260 100644
@@ -1496,6 +1496,17 @@ static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
        return 0;
 }
 
+static int ieee80211_get_mesh_stats(struct wiphy *wiphy,
+                                   struct net_device *dev,
+                                   struct mesh_stats *stats)
+{
+       struct ieee80211_sub_if_data *sdata;
+       sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+       memcpy(stats, &sdata->u.mesh.mshstats, sizeof(*stats));
+       return 0;
+}
+
 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
                                struct net_device *dev,
                                struct mesh_config *conf)
@@ -3082,6 +3093,7 @@ struct cfg80211_ops mac80211_config_ops = {
        .get_mpath = ieee80211_get_mpath,
        .dump_mpath = ieee80211_dump_mpath,
        .update_mesh_config = ieee80211_update_mesh_config,
+       .get_mesh_stats = ieee80211_get_mesh_stats,
        .get_mesh_config = ieee80211_get_mesh_config,
        .join_mesh = ieee80211_join_mesh,
        .leave_mesh = ieee80211_leave_mesh,
net/mac80211/ieee80211_i.h +0 -9
index 34f3cda..c30be38 100644
@@ -309,15 +309,6 @@ struct ieee80211_if_vlan {
        struct sta_info __rcu *sta;
 };
 
-struct mesh_stats {
-       __u32 fwded_mcast;              /* Mesh forwarded multicast frames */
-       __u32 fwded_unicast;            /* Mesh forwarded unicast frames */
-       __u32 fwded_frames;             /* Mesh total forwarded frames */
-       __u32 dropped_frames_ttl;       /* Not transmitted since mesh_ttl == 0*/
-       __u32 dropped_frames_no_route;  /* Not transmitted, no route found */
-       __u32 dropped_frames_congestion;/* Not forwarded due to congestion */
-};
-
 #define PREQ_Q_F_START         0x1
 #define PREQ_Q_F_REFRESH       0x2
 struct mesh_preq_queue {
net/wireless/nl80211.c +71 -1
index f1047ae..279a106 100644
@@ -275,6 +275,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
                                           .len = NL80211_MAX_SUPP_RATES },
        [NL80211_ATTR_BSS_HT_OPMODE] = { .type = NLA_U16 },
 
+       [NL80211_ATTR_MESH_STATS] = { .type = NLA_NESTED },
        [NL80211_ATTR_MESH_CONFIG] = { .type = NLA_NESTED },
        [NL80211_ATTR_SUPPORT_MESH_AUTH] = { .type = NLA_FLAG },
 
@@ -3645,6 +3646,68 @@ static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info)
        return r;
 }
 
+static int nl80211_get_mesh_stats(struct sk_buff *skb,
+                                 struct genl_info *info)
+{
+       struct cfg80211_registered_device *rdev = info->user_ptr[0];
+       struct net_device *dev = info->user_ptr[1];
+       struct wireless_dev *wdev = dev->ieee80211_ptr;
+       struct mesh_stats cur_stats;
+       int err = 0;
+       void *hdr;
+       struct nlattr *pinfoattr;
+       struct sk_buff *msg;
+
+       if (wdev->iftype != NL80211_IFTYPE_MESH_POINT)
+               return -EOPNOTSUPP;
+
+       if (!rdev->ops->get_mesh_stats)
+               return -EOPNOTSUPP;
+
+       wdev_lock(wdev);
+
+       err = rdev->ops->get_mesh_stats(&rdev->wiphy, dev, &cur_stats);
+       wdev_unlock(wdev);
+
+       if (err)
+               return err;
+
+       /* Draw up a netlink message to send back */
+       msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+       if (!msg)
+               return -ENOMEM;
+       hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
+                            NL80211_CMD_GET_MESH_STATS);
+       if (!hdr)
+               goto out;
+       pinfoattr = nla_nest_start(msg, NL80211_ATTR_MESH_STATS);
+       if (!pinfoattr)
+               goto nla_put_failure;
+       if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_FWDED_MCAST,
+                       cur_stats.fwded_mcast) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_FWDED_UNICAST,
+                       cur_stats.fwded_unicast) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_FWDED_FRAMES,
+                       cur_stats.fwded_frames) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_DROPPED_FRAMES_TTL,
+                       cur_stats.dropped_frames_ttl) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_DROPPED_FRAMES_NO_ROUTE,
+                       cur_stats.dropped_frames_no_route) ||
+           nla_put_u32(msg, NL80211_MESH_STATS_DROPPED_FRAMES_CONGESTION,
+                       cur_stats.dropped_frames_congestion))
+               goto nla_put_failure;
+       nla_nest_end(msg, pinfoattr);
+       genlmsg_end(msg, hdr);
+       return genlmsg_reply(msg, info);
+
+ nla_put_failure:
+       genlmsg_cancel(msg, hdr);
+ out:
+       nlmsg_free(msg);
+       return -ENOBUFS;
+}
+
 static int nl80211_get_mesh_config(struct sk_buff *skb,
                                   struct genl_info *info)
 {
@@ -7202,6 +7265,14 @@ static struct genl_ops nl80211_ops[] = {
                .flags = GENL_ADMIN_PERM,
        },
        {
+               .cmd = NL80211_CMD_GET_MESH_STATS,
+               .doit = nl80211_get_mesh_stats,
+               .policy = nl80211_policy,
+               /* can be retrieved by unprivileged users */
+               .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
+                                 NL80211_FLAG_NEED_RTNL,
+       },
+       {
                .cmd = NL80211_CMD_GET_MESH_CONFIG,
                .doit = nl80211_get_mesh_config,
                .policy = nl80211_policy,
--

1.7.5.4

Quoted 4 lines

_______________________________________________
Devel mailing list
[email protected]
http://lists.open80211s.org/cgi-bin/mailman/listinfo/devel

_______________________________________________
Devel mailing list
[email protected]
http://lists.open80211s.org/cgi-bin/mailman/listinfo/devel

Signature · 3 lines
Javier Cardona
cozybit Inc.
http://www.cozybit.com
maintainer Applied
#9 lore raw
In reply to Ashok Nagarajan
Quoted 2 lines · Ashok Nagarajan

estab_plinks is not a statistics member. Hence move estab_plinks from struct mesh_stat to struct ieee80211_if_mesh

Applied.

johannes

maintainer
#5 lore raw

Re: [PATCH 2/2] [nl,cfg,mac]80211: Add nl80211 command to get mesh network statistics

In reply to Ashok Nagarajan
Quoted 10 lines · Ashok Nagarajan

The command NL80211_CMD_GET_MESH_STATS gets the statistical information about the mesh network. Currently, the following statistics are provided:

1. Mesh forwarded multicast frames
2. Mesh forwarded unicast frames
3. Mesh total forwarded frames
4. Dropped frames due to mesh_ttl == 0
5. Dropped frames due to no route found
6. Dropped frames due to congestion

Quoted 3 lines

The attibute NL80211_ATTR_MESH_PARAMS enumerates the various mesh statistical parameters. A new call back get_mesh_stats() is added. mesh_stats struct is moved from mac80211/ieee80211_i.h to net/cfg80211.h.

I'll need to think about this a bit. What I'm thinking:

* is a new nl80211 command really the same API?
* should ethtools stats be provided maybe (in addition?)

I think this is probably fine though.

Some additional comments on the patch itself:

Quoted 1 line

+struct mesh_stats {

That should probably get a cfg80211_ prefix?

include/net/cfg80211.h struct bss_parameters { · line 830

Quoted 1 line
include/net/cfg80211.h +1 -0
+	u32 fwded_mcast;

Should we change those to u64 while at it, since it's now part of the userspace API in nl80211?

net/mac80211/cfg.c static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, · line 1506

Quoted 8 lines
net/mac80211/cfg.c +8 -0
+static int ieee80211_get_mesh_stats(struct wiphy *wiphy,
+				    struct net_device *dev,
+				    struct mesh_stats *stats)
+{
+	struct ieee80211_sub_if_data *sdata;
+	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+	memcpy(stats, &sdata->u.mesh.mshstats, sizeof(*stats));

should this provide a way to say "I only have these stats" in case other people later implement it? OTOH, they can do that when they implement it and don't have all the stats.

johannes

#6 lore raw

Re: [PATCH 2/2] [nl,cfg,mac]80211: Add nl80211 command to get mesh network statistics

Hello Johannes,

Thanks for your comments.

Quoted 11 lines · Johannes Berg
Quoted 10 lines · Ashok Nagarajan

The command NL80211_CMD_GET_MESH_STATS gets the statistical information about the mesh network. Currently, the following statistics are provided:

1. Mesh forwarded multicast frames
2. Mesh forwarded unicast frames
3. Mesh total forwarded frames
4. Dropped frames due to mesh_ttl == 0
5. Dropped frames due to no route found
6. Dropped frames due to congestion

Quoted 9 lines
Quoted 3 lines

The attibute NL80211_ATTR_MESH_PARAMS enumerates the various mesh statistical parameters. A new call back get_mesh_stats() is added. mesh_stats struct is moved from mac80211/ieee80211_i.h to net/cfg80211.h.

I'll need to think about this a bit. What I'm thinking:

* is a new nl80211 command really the same API?
* should ethtools stats be provided maybe (in addition?)

We didn't consider ethtools when implementing this. It seems to be a good approach. I will send a patch to address the same.

Thanks,
Ashok

Quoted 29 lines

I think this is probably fine though.

Some additional comments on the patch itself:

Quoted 1 line

+struct mesh_stats {

That should probably get a cfg80211_ prefix?

Quoted 1 line

+ u32 fwded_mcast;

Should we change those to u64 while at it, since it's now part of the userspace API in nl80211?

net/mac80211/cfg.c static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, · line 1506

Quoted 8 lines
net/mac80211/cfg.c +8 -0
+static int ieee80211_get_mesh_stats(struct wiphy *wiphy,
+                                 struct net_device *dev,
+                                 struct mesh_stats *stats)
+{
+     struct ieee80211_sub_if_data *sdata;
+     sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+     memcpy(stats, &sdata->u.mesh.mshstats, sizeof(*stats));

should this provide a way to say "I only have these stats" in case other people later implement it? OTOH, they can do that when they implement it and don't have all the stats.

johannes

maintainer
#7 lore raw

Re: [PATCH 2/2] [nl,cfg,mac]80211: Add nl80211 command to get mesh network statistics

In reply to Ashok Nagarajan
Quoted 12 lines · Ashok Nagarajan

/**
+ * struct mesh_stats - 802.11s mesh statistics
+ *
+ * Used to provide statistical information about mesh
+ *
+ * @fwded_mcast: Mesh forwarded multicast frames
+ * @fwded_unicast: Mesh forwarded unicast frames
+ * @fwded_frames: Mesh total forwarded frames
+ * @dropped_frames_ttl: Not transmitted since mesh_ttl == 0
+ * @dropped_frames_no_route: Not transmitted, no route found
+ * @dropped_frames_congestion: Not forwarded due to congestion
+ */

include/net/cfg80211.h struct bss_parameters { · line 830

Quoted 2 lines
include/net/cfg80211.h +2 -0
+struct mesh_stats {
+	u32 fwded_mcast;

Would it make sense to use u64 right away? A lot of netdev stats were at some point extended from u32 to u64 and that caused problems, maybe using u64 right away here would be good?

johannes

#8 lore raw

Re: [PATCH 2/2] [nl,cfg,mac]80211: Add nl80211 command to get mesh network statistics

Quoted 17 lines · Johannes Berg
Quoted 12 lines · Ashok Nagarajan

/**
+ * struct mesh_stats - 802.11s mesh statistics
+ *
+ * Used to provide statistical information about mesh
+ *
+ * @fwded_mcast: Mesh forwarded multicast frames
+ * @fwded_unicast: Mesh forwarded unicast frames
+ * @fwded_frames: Mesh total forwarded frames
+ * @dropped_frames_ttl: Not transmitted since mesh_ttl == 0
+ * @dropped_frames_no_route: Not transmitted, no route found
+ * @dropped_frames_congestion: Not forwarded due to congestion
+ */

include/net/cfg80211.h struct bss_parameters { · line 830

Quoted 2 lines
include/net/cfg80211.h +2 -0
+struct mesh_stats {
+     u32 fwded_mcast;
Quoted 3 lines

Would it make sense to use u64 right away? A lot of netdev stats were at some point extended from u32 to u64 and that caused problems, maybe using u64 right away here would be good?

Definitely.

Javier

Signature · 3 lines
Javier Cardona
cozybit Inc.
http://www.cozybit.com