1 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
6 #include <linux/netdevice.h>
7 #include <linux/if_ether.h>
8 #include <linux/if_arp.h>
43 static int __lbs_mesh_config_send(
struct lbs_private *priv,
73 static int lbs_mesh_config_send(
struct lbs_private *priv,
82 ret = __lbs_mesh_config_send(priv, cmd, action, type);
98 memset(&cmd, 0,
sizeof(cmd));
105 ie->
val.oui[0] = 0x00;
106 ie->
val.oui[1] = 0x50;
107 ie->
val.oui[2] = 0x43;
114 ie->
val.mesh_id_len = priv->mesh_ssid_len;
115 memcpy(ie->
val.mesh_id, priv->mesh_ssid, priv->mesh_ssid_len);
125 lbs_deb_cmd(
"mesh config action %d type %x channel %d SSID %s\n",
126 action, priv->mesh_tlv, chan,
129 return __lbs_mesh_config_send(priv, &cmd, action, priv->mesh_tlv);
140 return priv->mesh_channel ?: 1;
164 memset(&mesh_access, 0,
sizeof(mesh_access));
188 memset(&mesh_access, 0,
sizeof(mesh_access));
189 sscanf(buf,
"%x", &datum);
213 memset(&mesh_access, 0,
sizeof(mesh_access));
222 return snprintf(buf, 10,
"%d\n", retry_limit);
238 unsigned long retry_limit;
240 memset(&mesh_access, 0,
sizeof(mesh_access));
245 if (retry_limit > 15)
284 sscanf(buf,
"%x", &enable);
301 static DEVICE_ATTR(lbs_mesh, 0644, lbs_mesh_get, lbs_mesh_set);
307 static DEVICE_ATTR(anycast_mask, 0644, lbs_anycast_get, lbs_anycast_set);
313 static DEVICE_ATTR(prb_rsp_limit, 0644, lbs_prb_rsp_limit_get,
314 lbs_prb_rsp_limit_set);
316 static struct attribute *lbs_mesh_sysfs_entries[] = {
317 &dev_attr_anycast_mask.attr,
318 &dev_attr_prb_rsp_limit.attr,
323 .attrs = lbs_mesh_sysfs_entries,
331 static int mesh_get_default_parameters(
struct device *dev,
362 ret = mesh_get_default_parameters(dev, &defs);
378 const char *buf,
size_t count)
385 memset(&cmd, 0,
sizeof(cmd));
386 ret =
sscanf(buf,
"%d", &datum);
387 if ((ret != 1) || (datum > 1))
412 ret = mesh_get_default_parameters(dev, &defs);
435 memset(&cmd, 0,
sizeof(cmd));
436 ret =
sscanf(buf,
"%d", &datum);
437 if ((ret != 1) || (datum > 255))
448 datum = (datum < 20) ? 20 : datum;
471 ret = mesh_get_default_parameters(dev, &defs);
487 const char *buf,
size_t count)
494 memset(&cmd, 0,
sizeof(cmd));
495 ret =
sscanf(buf,
"%d", &datum);
496 if (ret != 1 || datum < 1 || datum > 11)
521 ret = mesh_get_default_parameters(dev, &defs);
527 dev_err(dev,
"inconsistent mesh ID length\n");
532 buf[defs.
meshie.val.mesh_id_len] =
'\n';
533 buf[defs.
meshie.val.mesh_id_len + 1] =
'\0';
535 return defs.
meshie.val.mesh_id_len + 1;
546 const char *buf,
size_t count)
562 ret = mesh_get_default_parameters(dev, &defs);
572 ie->
val.mesh_id_len =
len;
596 ret = mesh_get_default_parameters(dev, &defs);
601 return snprintf(buf, 5,
"%d\n", defs.
meshie.val.active_protocol_id);
621 memset(&cmd, 0,
sizeof(cmd));
622 ret =
sscanf(buf,
"%d", &datum);
623 if ((ret != 1) || (datum > 255))
627 ret = mesh_get_default_parameters(dev, &defs);
635 ie->
val.active_protocol_id = datum;
657 ret = mesh_get_default_parameters(dev, &defs);
662 return snprintf(buf, 5,
"%d\n", defs.
meshie.val.active_metric_id);
673 const char *buf,
size_t count)
682 memset(&cmd, 0,
sizeof(cmd));
683 ret =
sscanf(buf,
"%d", &datum);
684 if ((ret != 1) || (datum > 255))
688 ret = mesh_get_default_parameters(dev, &defs);
696 ie->
val.active_metric_id = datum;
718 ret = mesh_get_default_parameters(dev, &defs);
734 const char *buf,
size_t count)
743 memset(&cmd, 0,
sizeof(cmd));
744 ret =
sscanf(buf,
"%d", &datum);
745 if ((ret != 1) || (datum > 255))
749 ret = mesh_get_default_parameters(dev, &defs);
757 ie->
val.mesh_capability = datum;
768 static DEVICE_ATTR(bootflag, 0644, bootflag_get, bootflag_set);
769 static DEVICE_ATTR(boottime, 0644, boottime_get, boottime_set);
771 static DEVICE_ATTR(mesh_id, 0644, mesh_id_get, mesh_id_set);
772 static DEVICE_ATTR(protocol_id, 0644, protocol_id_get, protocol_id_set);
773 static DEVICE_ATTR(metric_id, 0644, metric_id_get, metric_id_set);
776 static struct attribute *boot_opts_attrs[] = {
777 &dev_attr_bootflag.attr,
778 &dev_attr_boottime.attr,
779 &dev_attr_channel.attr,
784 .name =
"boot_options",
785 .attrs = boot_opts_attrs,
788 static struct attribute *mesh_ie_attrs[] = {
789 &dev_attr_mesh_id.attr,
790 &dev_attr_protocol_id.attr,
791 &dev_attr_metric_id.attr,
792 &dev_attr_capability.attr,
798 .attrs = mesh_ie_attrs,
801 static void lbs_persist_config_init(
struct net_device *dev)
808 static void lbs_persist_config_remove(
struct net_device *dev)
868 if (priv->mesh_tlv) {
869 sprintf(priv->mesh_ssid,
"mesh");
870 priv->mesh_ssid_len = 4;
883 netdev_err(priv->
dev,
"cannot register lbs_mesh attribute\n");
893 if (priv->mesh_tlv) {
909 static int lbs_mesh_stop(
struct net_device *dev)
915 lbs_mesh_get_channel(priv));
919 netif_stop_queue(dev);
925 if (!lbs_iface_active(priv))
938 static int lbs_mesh_dev_open(
struct net_device *dev)
961 netif_wake_queue(dev);
966 lbs_mesh_get_channel(priv));
974 .ndo_open = lbs_mesh_dev_open,
975 .ndo_stop = lbs_mesh_stop,
1012 mesh_wdev->
netdev = mesh_dev;
1028 pr_err(
"cannot register mshX virtual interface\n");
1029 goto err_free_netdev;
1034 goto err_unregister;
1036 lbs_persist_config_init(mesh_dev);
1065 netif_stop_queue(mesh_dev);
1068 lbs_persist_config_remove(mesh_dev);
1112 static const char *
const mesh_stat_strings[] = {
1113 "drop_duplicate_bcast",
1115 "drop_no_fwd_route",
1117 "fwded_unicast_cnt",
1149 data[0] = priv->mstats.fwd_drop_rbt;
1150 data[1] = priv->mstats.fwd_drop_ttl;
1151 data[2] = priv->mstats.fwd_drop_noroute;
1152 data[3] = priv->mstats.fwd_drop_nobuf;
1153 data[4] = priv->mstats.fwd_unicast_cnt;
1154 data[5] = priv->mstats.fwd_bcast_cnt;
1155 data[6] = priv->mstats.drop_blind;
1156 data[7] = priv->mstats.tx_failed_cnt;
1178 switch (stringset) {
1182 mesh_stat_strings[i],