Joe Perches | 0e4e06a | 2011-05-02 16:49:14 -0700 | [diff] [blame] | 1 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 2 | |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 3 | #include <linux/delay.h> |
| 4 | #include <linux/etherdevice.h> |
Alexey Dobriyan | a6b7a40 | 2011-06-06 10:43:46 +0000 | [diff] [blame] | 5 | #include <linux/hardirq.h> |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 6 | #include <linux/netdevice.h> |
Daniel Drake | 1f04493 | 2009-12-24 08:11:24 +0000 | [diff] [blame] | 7 | #include <linux/if_ether.h> |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 8 | #include <linux/if_arp.h> |
| 9 | #include <linux/kthread.h> |
| 10 | #include <linux/kfifo.h> |
Kiran Divekar | e86dc1c | 2010-06-14 22:01:26 +0530 | [diff] [blame] | 11 | #include <net/cfg80211.h> |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 12 | |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 13 | #include "mesh.h" |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 14 | #include "decl.h" |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 15 | #include "cmd.h" |
| 16 | |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 17 | |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 18 | static int lbs_add_mesh(struct lbs_private *priv); |
| 19 | |
| 20 | /*************************************************************************** |
| 21 | * Mesh command handling |
| 22 | */ |
| 23 | |
| 24 | static int lbs_mesh_access(struct lbs_private *priv, uint16_t cmd_action, |
| 25 | struct cmd_ds_mesh_access *cmd) |
| 26 | { |
| 27 | int ret; |
| 28 | |
| 29 | lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); |
| 30 | |
| 31 | cmd->hdr.command = cpu_to_le16(CMD_MESH_ACCESS); |
| 32 | cmd->hdr.size = cpu_to_le16(sizeof(*cmd)); |
| 33 | cmd->hdr.result = 0; |
| 34 | |
| 35 | cmd->action = cpu_to_le16(cmd_action); |
| 36 | |
| 37 | ret = lbs_cmd_with_response(priv, CMD_MESH_ACCESS, cmd); |
| 38 | |
| 39 | lbs_deb_leave(LBS_DEB_CMD); |
| 40 | return ret; |
| 41 | } |
| 42 | |
| 43 | static int __lbs_mesh_config_send(struct lbs_private *priv, |
| 44 | struct cmd_ds_mesh_config *cmd, |
| 45 | uint16_t action, uint16_t type) |
| 46 | { |
| 47 | int ret; |
| 48 | u16 command = CMD_MESH_CONFIG_OLD; |
| 49 | |
| 50 | lbs_deb_enter(LBS_DEB_CMD); |
| 51 | |
| 52 | /* |
| 53 | * Command id is 0xac for v10 FW along with mesh interface |
| 54 | * id in bits 14-13-12. |
| 55 | */ |
| 56 | if (priv->mesh_tlv == TLV_TYPE_MESH_ID) |
| 57 | command = CMD_MESH_CONFIG | |
| 58 | (MESH_IFACE_ID << MESH_IFACE_BIT_OFFSET); |
| 59 | |
| 60 | cmd->hdr.command = cpu_to_le16(command); |
| 61 | cmd->hdr.size = cpu_to_le16(sizeof(struct cmd_ds_mesh_config)); |
| 62 | cmd->hdr.result = 0; |
| 63 | |
| 64 | cmd->type = cpu_to_le16(type); |
| 65 | cmd->action = cpu_to_le16(action); |
| 66 | |
| 67 | ret = lbs_cmd_with_response(priv, command, cmd); |
| 68 | |
| 69 | lbs_deb_leave(LBS_DEB_CMD); |
| 70 | return ret; |
| 71 | } |
| 72 | |
| 73 | static int lbs_mesh_config_send(struct lbs_private *priv, |
| 74 | struct cmd_ds_mesh_config *cmd, |
| 75 | uint16_t action, uint16_t type) |
| 76 | { |
| 77 | int ret; |
| 78 | |
| 79 | if (!(priv->fwcapinfo & FW_CAPINFO_PERSISTENT_CONFIG)) |
| 80 | return -EOPNOTSUPP; |
| 81 | |
| 82 | ret = __lbs_mesh_config_send(priv, cmd, action, type); |
| 83 | return ret; |
| 84 | } |
| 85 | |
| 86 | /* This function is the CMD_MESH_CONFIG legacy function. It only handles the |
| 87 | * START and STOP actions. The extended actions supported by CMD_MESH_CONFIG |
| 88 | * are all handled by preparing a struct cmd_ds_mesh_config and passing it to |
| 89 | * lbs_mesh_config_send. |
| 90 | */ |
| 91 | static int lbs_mesh_config(struct lbs_private *priv, uint16_t action, |
| 92 | uint16_t chan) |
| 93 | { |
| 94 | struct cmd_ds_mesh_config cmd; |
| 95 | struct mrvl_meshie *ie; |
| 96 | DECLARE_SSID_BUF(ssid); |
| 97 | |
| 98 | memset(&cmd, 0, sizeof(cmd)); |
| 99 | cmd.channel = cpu_to_le16(chan); |
| 100 | ie = (struct mrvl_meshie *)cmd.data; |
| 101 | |
| 102 | switch (action) { |
| 103 | case CMD_ACT_MESH_CONFIG_START: |
| 104 | ie->id = WLAN_EID_GENERIC; |
| 105 | ie->val.oui[0] = 0x00; |
| 106 | ie->val.oui[1] = 0x50; |
| 107 | ie->val.oui[2] = 0x43; |
| 108 | ie->val.type = MARVELL_MESH_IE_TYPE; |
| 109 | ie->val.subtype = MARVELL_MESH_IE_SUBTYPE; |
| 110 | ie->val.version = MARVELL_MESH_IE_VERSION; |
| 111 | ie->val.active_protocol_id = MARVELL_MESH_PROTO_ID_HWMP; |
| 112 | ie->val.active_metric_id = MARVELL_MESH_METRIC_ID; |
| 113 | ie->val.mesh_capability = MARVELL_MESH_CAPABILITY; |
| 114 | ie->val.mesh_id_len = priv->mesh_ssid_len; |
| 115 | memcpy(ie->val.mesh_id, priv->mesh_ssid, priv->mesh_ssid_len); |
| 116 | ie->len = sizeof(struct mrvl_meshie_val) - |
| 117 | IEEE80211_MAX_SSID_LEN + priv->mesh_ssid_len; |
| 118 | cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie_val)); |
| 119 | break; |
| 120 | case CMD_ACT_MESH_CONFIG_STOP: |
| 121 | break; |
| 122 | default: |
| 123 | return -1; |
| 124 | } |
| 125 | lbs_deb_cmd("mesh config action %d type %x channel %d SSID %s\n", |
| 126 | action, priv->mesh_tlv, chan, |
| 127 | print_ssid(ssid, priv->mesh_ssid, priv->mesh_ssid_len)); |
| 128 | |
| 129 | return __lbs_mesh_config_send(priv, &cmd, action, priv->mesh_tlv); |
| 130 | } |
| 131 | |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 132 | int lbs_mesh_set_channel(struct lbs_private *priv, u8 channel) |
| 133 | { |
| 134 | return lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, channel); |
| 135 | } |
| 136 | |
| 137 | static uint16_t lbs_mesh_get_channel(struct lbs_private *priv) |
| 138 | { |
| 139 | struct wireless_dev *mesh_wdev = priv->mesh_dev->ieee80211_ptr; |
| 140 | if (mesh_wdev->channel) |
| 141 | return mesh_wdev->channel->hw_value; |
| 142 | else |
| 143 | return 1; |
| 144 | } |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 145 | |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 146 | /*************************************************************************** |
| 147 | * Mesh sysfs support |
| 148 | */ |
| 149 | |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 150 | /* |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 151 | * Attributes exported through sysfs |
| 152 | */ |
| 153 | |
| 154 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 155 | * lbs_anycast_get - Get function for sysfs attribute anycast_mask |
| 156 | * @dev: the &struct device |
| 157 | * @attr: device attributes |
| 158 | * @buf: buffer where data will be returned |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 159 | */ |
| 160 | static ssize_t lbs_anycast_get(struct device *dev, |
| 161 | struct device_attribute *attr, char * buf) |
| 162 | { |
| 163 | struct lbs_private *priv = to_net_dev(dev)->ml_priv; |
| 164 | struct cmd_ds_mesh_access mesh_access; |
| 165 | int ret; |
| 166 | |
| 167 | memset(&mesh_access, 0, sizeof(mesh_access)); |
| 168 | |
| 169 | ret = lbs_mesh_access(priv, CMD_ACT_MESH_GET_ANYCAST, &mesh_access); |
| 170 | if (ret) |
| 171 | return ret; |
| 172 | |
| 173 | return snprintf(buf, 12, "0x%X\n", le32_to_cpu(mesh_access.data[0])); |
| 174 | } |
| 175 | |
| 176 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 177 | * lbs_anycast_set - Set function for sysfs attribute anycast_mask |
| 178 | * @dev: the &struct device |
| 179 | * @attr: device attributes |
| 180 | * @buf: buffer that contains new attribute value |
| 181 | * @count: size of buffer |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 182 | */ |
| 183 | static ssize_t lbs_anycast_set(struct device *dev, |
| 184 | struct device_attribute *attr, const char * buf, size_t count) |
| 185 | { |
| 186 | struct lbs_private *priv = to_net_dev(dev)->ml_priv; |
| 187 | struct cmd_ds_mesh_access mesh_access; |
| 188 | uint32_t datum; |
| 189 | int ret; |
| 190 | |
| 191 | memset(&mesh_access, 0, sizeof(mesh_access)); |
| 192 | sscanf(buf, "%x", &datum); |
| 193 | mesh_access.data[0] = cpu_to_le32(datum); |
| 194 | |
| 195 | ret = lbs_mesh_access(priv, CMD_ACT_MESH_SET_ANYCAST, &mesh_access); |
| 196 | if (ret) |
| 197 | return ret; |
| 198 | |
| 199 | return strlen(buf); |
| 200 | } |
| 201 | |
| 202 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 203 | * lbs_prb_rsp_limit_get - Get function for sysfs attribute prb_rsp_limit |
| 204 | * @dev: the &struct device |
| 205 | * @attr: device attributes |
| 206 | * @buf: buffer where data will be returned |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 207 | */ |
| 208 | static ssize_t lbs_prb_rsp_limit_get(struct device *dev, |
| 209 | struct device_attribute *attr, char *buf) |
| 210 | { |
| 211 | struct lbs_private *priv = to_net_dev(dev)->ml_priv; |
| 212 | struct cmd_ds_mesh_access mesh_access; |
| 213 | int ret; |
| 214 | u32 retry_limit; |
| 215 | |
| 216 | memset(&mesh_access, 0, sizeof(mesh_access)); |
| 217 | mesh_access.data[0] = cpu_to_le32(CMD_ACT_GET); |
| 218 | |
| 219 | ret = lbs_mesh_access(priv, CMD_ACT_MESH_SET_GET_PRB_RSP_LIMIT, |
| 220 | &mesh_access); |
| 221 | if (ret) |
| 222 | return ret; |
| 223 | |
| 224 | retry_limit = le32_to_cpu(mesh_access.data[1]); |
| 225 | return snprintf(buf, 10, "%d\n", retry_limit); |
| 226 | } |
| 227 | |
| 228 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 229 | * lbs_prb_rsp_limit_set - Set function for sysfs attribute prb_rsp_limit |
| 230 | * @dev: the &struct device |
| 231 | * @attr: device attributes |
| 232 | * @buf: buffer that contains new attribute value |
| 233 | * @count: size of buffer |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 234 | */ |
| 235 | static ssize_t lbs_prb_rsp_limit_set(struct device *dev, |
| 236 | struct device_attribute *attr, const char *buf, size_t count) |
| 237 | { |
| 238 | struct lbs_private *priv = to_net_dev(dev)->ml_priv; |
| 239 | struct cmd_ds_mesh_access mesh_access; |
| 240 | int ret; |
| 241 | unsigned long retry_limit; |
| 242 | |
| 243 | memset(&mesh_access, 0, sizeof(mesh_access)); |
| 244 | mesh_access.data[0] = cpu_to_le32(CMD_ACT_SET); |
| 245 | |
| 246 | if (!strict_strtoul(buf, 10, &retry_limit)) |
| 247 | return -ENOTSUPP; |
| 248 | if (retry_limit > 15) |
| 249 | return -ENOTSUPP; |
| 250 | |
| 251 | mesh_access.data[1] = cpu_to_le32(retry_limit); |
| 252 | |
| 253 | ret = lbs_mesh_access(priv, CMD_ACT_MESH_SET_GET_PRB_RSP_LIMIT, |
| 254 | &mesh_access); |
| 255 | if (ret) |
| 256 | return ret; |
| 257 | |
| 258 | return strlen(buf); |
| 259 | } |
| 260 | |
| 261 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 262 | * lbs_mesh_get - Get function for sysfs attribute mesh |
| 263 | * @dev: the &struct device |
| 264 | * @attr: device attributes |
| 265 | * @buf: buffer where data will be returned |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 266 | */ |
| 267 | static ssize_t lbs_mesh_get(struct device *dev, |
| 268 | struct device_attribute *attr, char * buf) |
| 269 | { |
| 270 | struct lbs_private *priv = to_net_dev(dev)->ml_priv; |
| 271 | return snprintf(buf, 5, "0x%X\n", !!priv->mesh_dev); |
| 272 | } |
| 273 | |
| 274 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 275 | * lbs_mesh_set - Set function for sysfs attribute mesh |
| 276 | * @dev: the &struct device |
| 277 | * @attr: device attributes |
| 278 | * @buf: buffer that contains new attribute value |
| 279 | * @count: size of buffer |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 280 | */ |
| 281 | static ssize_t lbs_mesh_set(struct device *dev, |
| 282 | struct device_attribute *attr, const char * buf, size_t count) |
| 283 | { |
| 284 | struct lbs_private *priv = to_net_dev(dev)->ml_priv; |
| 285 | int enable; |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 286 | |
| 287 | sscanf(buf, "%x", &enable); |
| 288 | enable = !!enable; |
| 289 | if (enable == !!priv->mesh_dev) |
| 290 | return count; |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 291 | |
| 292 | if (enable) |
| 293 | lbs_add_mesh(priv); |
| 294 | else |
| 295 | lbs_remove_mesh(priv); |
| 296 | |
| 297 | return count; |
| 298 | } |
| 299 | |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 300 | /* |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 301 | * lbs_mesh attribute to be exported per ethX interface |
| 302 | * through sysfs (/sys/class/net/ethX/lbs_mesh) |
| 303 | */ |
| 304 | static DEVICE_ATTR(lbs_mesh, 0644, lbs_mesh_get, lbs_mesh_set); |
| 305 | |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 306 | /* |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 307 | * anycast_mask attribute to be exported per mshX interface |
| 308 | * through sysfs (/sys/class/net/mshX/anycast_mask) |
| 309 | */ |
| 310 | static DEVICE_ATTR(anycast_mask, 0644, lbs_anycast_get, lbs_anycast_set); |
| 311 | |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 312 | /* |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 313 | * prb_rsp_limit attribute to be exported per mshX interface |
| 314 | * through sysfs (/sys/class/net/mshX/prb_rsp_limit) |
| 315 | */ |
| 316 | static DEVICE_ATTR(prb_rsp_limit, 0644, lbs_prb_rsp_limit_get, |
| 317 | lbs_prb_rsp_limit_set); |
| 318 | |
| 319 | static struct attribute *lbs_mesh_sysfs_entries[] = { |
| 320 | &dev_attr_anycast_mask.attr, |
| 321 | &dev_attr_prb_rsp_limit.attr, |
| 322 | NULL, |
| 323 | }; |
| 324 | |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 325 | static const struct attribute_group lbs_mesh_attr_group = { |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 326 | .attrs = lbs_mesh_sysfs_entries, |
| 327 | }; |
| 328 | |
| 329 | |
Holger Schurig | ece1e3c | 2009-11-25 13:11:16 +0100 | [diff] [blame] | 330 | /*************************************************************************** |
Holger Schurig | e0e42da | 2009-11-25 13:10:15 +0100 | [diff] [blame] | 331 | * Persistent configuration support |
| 332 | */ |
| 333 | |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 334 | static int mesh_get_default_parameters(struct device *dev, |
| 335 | struct mrvl_mesh_defaults *defs) |
| 336 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 337 | struct lbs_private *priv = to_net_dev(dev)->ml_priv; |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 338 | struct cmd_ds_mesh_config cmd; |
| 339 | int ret; |
| 340 | |
| 341 | memset(&cmd, 0, sizeof(struct cmd_ds_mesh_config)); |
| 342 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_GET, |
| 343 | CMD_TYPE_MESH_GET_DEFAULTS); |
| 344 | |
| 345 | if (ret) |
| 346 | return -EOPNOTSUPP; |
| 347 | |
| 348 | memcpy(defs, &cmd.data[0], sizeof(struct mrvl_mesh_defaults)); |
| 349 | |
| 350 | return 0; |
| 351 | } |
| 352 | |
| 353 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 354 | * bootflag_get - Get function for sysfs attribute bootflag |
| 355 | * @dev: the &struct device |
| 356 | * @attr: device attributes |
| 357 | * @buf: buffer where data will be returned |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 358 | */ |
| 359 | static ssize_t bootflag_get(struct device *dev, |
| 360 | struct device_attribute *attr, char *buf) |
| 361 | { |
| 362 | struct mrvl_mesh_defaults defs; |
| 363 | int ret; |
| 364 | |
| 365 | ret = mesh_get_default_parameters(dev, &defs); |
| 366 | |
| 367 | if (ret) |
| 368 | return ret; |
| 369 | |
Brian Cavagnolo | fb90490 | 2008-07-16 12:15:26 -0700 | [diff] [blame] | 370 | return snprintf(buf, 12, "%d\n", le32_to_cpu(defs.bootflag)); |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 374 | * bootflag_set - Set function for sysfs attribute bootflag |
| 375 | * @dev: the &struct device |
| 376 | * @attr: device attributes |
| 377 | * @buf: buffer that contains new attribute value |
| 378 | * @count: size of buffer |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 379 | */ |
| 380 | static ssize_t bootflag_set(struct device *dev, struct device_attribute *attr, |
| 381 | const char *buf, size_t count) |
| 382 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 383 | struct lbs_private *priv = to_net_dev(dev)->ml_priv; |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 384 | struct cmd_ds_mesh_config cmd; |
| 385 | uint32_t datum; |
| 386 | int ret; |
| 387 | |
| 388 | memset(&cmd, 0, sizeof(cmd)); |
Brian Cavagnolo | fb90490 | 2008-07-16 12:15:26 -0700 | [diff] [blame] | 389 | ret = sscanf(buf, "%d", &datum); |
| 390 | if ((ret != 1) || (datum > 1)) |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 391 | return -EINVAL; |
| 392 | |
| 393 | *((__le32 *)&cmd.data[0]) = cpu_to_le32(!!datum); |
| 394 | cmd.length = cpu_to_le16(sizeof(uint32_t)); |
| 395 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, |
| 396 | CMD_TYPE_MESH_SET_BOOTFLAG); |
| 397 | if (ret) |
| 398 | return ret; |
| 399 | |
| 400 | return strlen(buf); |
| 401 | } |
| 402 | |
| 403 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 404 | * boottime_get - Get function for sysfs attribute boottime |
| 405 | * @dev: the &struct device |
| 406 | * @attr: device attributes |
| 407 | * @buf: buffer where data will be returned |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 408 | */ |
| 409 | static ssize_t boottime_get(struct device *dev, |
| 410 | struct device_attribute *attr, char *buf) |
| 411 | { |
| 412 | struct mrvl_mesh_defaults defs; |
| 413 | int ret; |
| 414 | |
| 415 | ret = mesh_get_default_parameters(dev, &defs); |
| 416 | |
| 417 | if (ret) |
| 418 | return ret; |
| 419 | |
Brian Cavagnolo | fb90490 | 2008-07-16 12:15:26 -0700 | [diff] [blame] | 420 | return snprintf(buf, 12, "%d\n", defs.boottime); |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 424 | * boottime_set - Set function for sysfs attribute boottime |
| 425 | * @dev: the &struct device |
| 426 | * @attr: device attributes |
| 427 | * @buf: buffer that contains new attribute value |
| 428 | * @count: size of buffer |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 429 | */ |
| 430 | static ssize_t boottime_set(struct device *dev, |
| 431 | struct device_attribute *attr, const char *buf, size_t count) |
| 432 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 433 | struct lbs_private *priv = to_net_dev(dev)->ml_priv; |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 434 | struct cmd_ds_mesh_config cmd; |
| 435 | uint32_t datum; |
| 436 | int ret; |
| 437 | |
| 438 | memset(&cmd, 0, sizeof(cmd)); |
Brian Cavagnolo | fb90490 | 2008-07-16 12:15:26 -0700 | [diff] [blame] | 439 | ret = sscanf(buf, "%d", &datum); |
| 440 | if ((ret != 1) || (datum > 255)) |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 441 | return -EINVAL; |
| 442 | |
| 443 | /* A too small boot time will result in the device booting into |
| 444 | * standalone (no-host) mode before the host can take control of it, |
| 445 | * so the change will be hard to revert. This may be a desired |
| 446 | * feature (e.g to configure a very fast boot time for devices that |
| 447 | * will not be attached to a host), but dangerous. So I'm enforcing a |
| 448 | * lower limit of 20 seconds: remove and recompile the driver if this |
| 449 | * does not work for you. |
| 450 | */ |
| 451 | datum = (datum < 20) ? 20 : datum; |
| 452 | cmd.data[0] = datum; |
| 453 | cmd.length = cpu_to_le16(sizeof(uint8_t)); |
| 454 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, |
| 455 | CMD_TYPE_MESH_SET_BOOTTIME); |
| 456 | if (ret) |
| 457 | return ret; |
| 458 | |
| 459 | return strlen(buf); |
| 460 | } |
| 461 | |
| 462 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 463 | * channel_get - Get function for sysfs attribute channel |
| 464 | * @dev: the &struct device |
| 465 | * @attr: device attributes |
| 466 | * @buf: buffer where data will be returned |
Javier Cardona | b679aeb | 2008-05-20 15:18:49 -0700 | [diff] [blame] | 467 | */ |
| 468 | static ssize_t channel_get(struct device *dev, |
| 469 | struct device_attribute *attr, char *buf) |
| 470 | { |
| 471 | struct mrvl_mesh_defaults defs; |
| 472 | int ret; |
| 473 | |
| 474 | ret = mesh_get_default_parameters(dev, &defs); |
| 475 | |
| 476 | if (ret) |
| 477 | return ret; |
| 478 | |
Brian Cavagnolo | fb90490 | 2008-07-16 12:15:26 -0700 | [diff] [blame] | 479 | return snprintf(buf, 12, "%d\n", le16_to_cpu(defs.channel)); |
Javier Cardona | b679aeb | 2008-05-20 15:18:49 -0700 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 483 | * channel_set - Set function for sysfs attribute channel |
| 484 | * @dev: the &struct device |
| 485 | * @attr: device attributes |
| 486 | * @buf: buffer that contains new attribute value |
| 487 | * @count: size of buffer |
Javier Cardona | b679aeb | 2008-05-20 15:18:49 -0700 | [diff] [blame] | 488 | */ |
| 489 | static ssize_t channel_set(struct device *dev, struct device_attribute *attr, |
| 490 | const char *buf, size_t count) |
| 491 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 492 | struct lbs_private *priv = to_net_dev(dev)->ml_priv; |
Javier Cardona | b679aeb | 2008-05-20 15:18:49 -0700 | [diff] [blame] | 493 | struct cmd_ds_mesh_config cmd; |
Brian Cavagnolo | fb90490 | 2008-07-16 12:15:26 -0700 | [diff] [blame] | 494 | uint32_t datum; |
Javier Cardona | b679aeb | 2008-05-20 15:18:49 -0700 | [diff] [blame] | 495 | int ret; |
| 496 | |
| 497 | memset(&cmd, 0, sizeof(cmd)); |
Brian Cavagnolo | fb90490 | 2008-07-16 12:15:26 -0700 | [diff] [blame] | 498 | ret = sscanf(buf, "%d", &datum); |
Javier Cardona | b679aeb | 2008-05-20 15:18:49 -0700 | [diff] [blame] | 499 | if (ret != 1 || datum < 1 || datum > 11) |
| 500 | return -EINVAL; |
| 501 | |
| 502 | *((__le16 *)&cmd.data[0]) = cpu_to_le16(datum); |
| 503 | cmd.length = cpu_to_le16(sizeof(uint16_t)); |
| 504 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, |
| 505 | CMD_TYPE_MESH_SET_DEF_CHANNEL); |
| 506 | if (ret) |
| 507 | return ret; |
| 508 | |
| 509 | return strlen(buf); |
| 510 | } |
| 511 | |
| 512 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 513 | * mesh_id_get - Get function for sysfs attribute mesh_id |
| 514 | * @dev: the &struct device |
| 515 | * @attr: device attributes |
| 516 | * @buf: buffer where data will be returned |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 517 | */ |
| 518 | static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr, |
| 519 | char *buf) |
| 520 | { |
| 521 | struct mrvl_mesh_defaults defs; |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 522 | int ret; |
| 523 | |
| 524 | ret = mesh_get_default_parameters(dev, &defs); |
| 525 | |
| 526 | if (ret) |
| 527 | return ret; |
| 528 | |
Holger Schurig | 243e84e | 2009-10-22 15:30:47 +0200 | [diff] [blame] | 529 | if (defs.meshie.val.mesh_id_len > IEEE80211_MAX_SSID_LEN) { |
Joe Perches | f3a57fd | 2011-05-02 16:49:15 -0700 | [diff] [blame] | 530 | dev_err(dev, "inconsistent mesh ID length\n"); |
Holger Schurig | 243e84e | 2009-10-22 15:30:47 +0200 | [diff] [blame] | 531 | defs.meshie.val.mesh_id_len = IEEE80211_MAX_SSID_LEN; |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 532 | } |
| 533 | |
Dan Carpenter | d89dba7 | 2011-03-10 18:23:26 +0300 | [diff] [blame] | 534 | memcpy(buf, defs.meshie.val.mesh_id, defs.meshie.val.mesh_id_len); |
| 535 | buf[defs.meshie.val.mesh_id_len] = '\n'; |
| 536 | buf[defs.meshie.val.mesh_id_len + 1] = '\0'; |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 537 | |
Dan Carpenter | d89dba7 | 2011-03-10 18:23:26 +0300 | [diff] [blame] | 538 | return defs.meshie.val.mesh_id_len + 1; |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 542 | * mesh_id_set - Set function for sysfs attribute mesh_id |
| 543 | * @dev: the &struct device |
| 544 | * @attr: device attributes |
| 545 | * @buf: buffer that contains new attribute value |
| 546 | * @count: size of buffer |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 547 | */ |
| 548 | static ssize_t mesh_id_set(struct device *dev, struct device_attribute *attr, |
| 549 | const char *buf, size_t count) |
| 550 | { |
| 551 | struct cmd_ds_mesh_config cmd; |
| 552 | struct mrvl_mesh_defaults defs; |
| 553 | struct mrvl_meshie *ie; |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 554 | struct lbs_private *priv = to_net_dev(dev)->ml_priv; |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 555 | int len; |
| 556 | int ret; |
| 557 | |
Holger Schurig | 243e84e | 2009-10-22 15:30:47 +0200 | [diff] [blame] | 558 | if (count < 2 || count > IEEE80211_MAX_SSID_LEN + 1) |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 559 | return -EINVAL; |
| 560 | |
| 561 | memset(&cmd, 0, sizeof(struct cmd_ds_mesh_config)); |
| 562 | ie = (struct mrvl_meshie *) &cmd.data[0]; |
| 563 | |
| 564 | /* fetch all other Information Element parameters */ |
| 565 | ret = mesh_get_default_parameters(dev, &defs); |
| 566 | |
| 567 | cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie)); |
| 568 | |
| 569 | /* transfer IE elements */ |
| 570 | memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie)); |
| 571 | |
| 572 | len = count - 1; |
| 573 | memcpy(ie->val.mesh_id, buf, len); |
| 574 | /* SSID len */ |
| 575 | ie->val.mesh_id_len = len; |
| 576 | /* IE len */ |
Holger Schurig | 243e84e | 2009-10-22 15:30:47 +0200 | [diff] [blame] | 577 | ie->len = sizeof(struct mrvl_meshie_val) - IEEE80211_MAX_SSID_LEN + len; |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 578 | |
| 579 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, |
| 580 | CMD_TYPE_MESH_SET_MESH_IE); |
| 581 | if (ret) |
| 582 | return ret; |
| 583 | |
| 584 | return strlen(buf); |
| 585 | } |
| 586 | |
| 587 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 588 | * protocol_id_get - Get function for sysfs attribute protocol_id |
| 589 | * @dev: the &struct device |
| 590 | * @attr: device attributes |
| 591 | * @buf: buffer where data will be returned |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 592 | */ |
| 593 | static ssize_t protocol_id_get(struct device *dev, |
| 594 | struct device_attribute *attr, char *buf) |
| 595 | { |
| 596 | struct mrvl_mesh_defaults defs; |
| 597 | int ret; |
| 598 | |
| 599 | ret = mesh_get_default_parameters(dev, &defs); |
| 600 | |
| 601 | if (ret) |
| 602 | return ret; |
| 603 | |
| 604 | return snprintf(buf, 5, "%d\n", defs.meshie.val.active_protocol_id); |
| 605 | } |
| 606 | |
| 607 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 608 | * protocol_id_set - Set function for sysfs attribute protocol_id |
| 609 | * @dev: the &struct device |
| 610 | * @attr: device attributes |
| 611 | * @buf: buffer that contains new attribute value |
| 612 | * @count: size of buffer |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 613 | */ |
| 614 | static ssize_t protocol_id_set(struct device *dev, |
| 615 | struct device_attribute *attr, const char *buf, size_t count) |
| 616 | { |
| 617 | struct cmd_ds_mesh_config cmd; |
| 618 | struct mrvl_mesh_defaults defs; |
| 619 | struct mrvl_meshie *ie; |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 620 | struct lbs_private *priv = to_net_dev(dev)->ml_priv; |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 621 | uint32_t datum; |
| 622 | int ret; |
| 623 | |
| 624 | memset(&cmd, 0, sizeof(cmd)); |
Brian Cavagnolo | fb90490 | 2008-07-16 12:15:26 -0700 | [diff] [blame] | 625 | ret = sscanf(buf, "%d", &datum); |
| 626 | if ((ret != 1) || (datum > 255)) |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 627 | return -EINVAL; |
| 628 | |
| 629 | /* fetch all other Information Element parameters */ |
| 630 | ret = mesh_get_default_parameters(dev, &defs); |
| 631 | |
| 632 | cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie)); |
| 633 | |
| 634 | /* transfer IE elements */ |
| 635 | ie = (struct mrvl_meshie *) &cmd.data[0]; |
| 636 | memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie)); |
| 637 | /* update protocol id */ |
| 638 | ie->val.active_protocol_id = datum; |
| 639 | |
| 640 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, |
| 641 | CMD_TYPE_MESH_SET_MESH_IE); |
| 642 | if (ret) |
| 643 | return ret; |
| 644 | |
| 645 | return strlen(buf); |
| 646 | } |
| 647 | |
| 648 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 649 | * metric_id_get - Get function for sysfs attribute metric_id |
| 650 | * @dev: the &struct device |
| 651 | * @attr: device attributes |
| 652 | * @buf: buffer where data will be returned |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 653 | */ |
| 654 | static ssize_t metric_id_get(struct device *dev, |
| 655 | struct device_attribute *attr, char *buf) |
| 656 | { |
| 657 | struct mrvl_mesh_defaults defs; |
| 658 | int ret; |
| 659 | |
| 660 | ret = mesh_get_default_parameters(dev, &defs); |
| 661 | |
| 662 | if (ret) |
| 663 | return ret; |
| 664 | |
| 665 | return snprintf(buf, 5, "%d\n", defs.meshie.val.active_metric_id); |
| 666 | } |
| 667 | |
| 668 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 669 | * metric_id_set - Set function for sysfs attribute metric_id |
| 670 | * @dev: the &struct device |
| 671 | * @attr: device attributes |
| 672 | * @buf: buffer that contains new attribute value |
| 673 | * @count: size of buffer |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 674 | */ |
| 675 | static ssize_t metric_id_set(struct device *dev, struct device_attribute *attr, |
| 676 | const char *buf, size_t count) |
| 677 | { |
| 678 | struct cmd_ds_mesh_config cmd; |
| 679 | struct mrvl_mesh_defaults defs; |
| 680 | struct mrvl_meshie *ie; |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 681 | struct lbs_private *priv = to_net_dev(dev)->ml_priv; |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 682 | uint32_t datum; |
| 683 | int ret; |
| 684 | |
| 685 | memset(&cmd, 0, sizeof(cmd)); |
Brian Cavagnolo | fb90490 | 2008-07-16 12:15:26 -0700 | [diff] [blame] | 686 | ret = sscanf(buf, "%d", &datum); |
| 687 | if ((ret != 1) || (datum > 255)) |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 688 | return -EINVAL; |
| 689 | |
| 690 | /* fetch all other Information Element parameters */ |
| 691 | ret = mesh_get_default_parameters(dev, &defs); |
| 692 | |
| 693 | cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie)); |
| 694 | |
| 695 | /* transfer IE elements */ |
| 696 | ie = (struct mrvl_meshie *) &cmd.data[0]; |
| 697 | memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie)); |
| 698 | /* update metric id */ |
| 699 | ie->val.active_metric_id = datum; |
| 700 | |
| 701 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, |
| 702 | CMD_TYPE_MESH_SET_MESH_IE); |
| 703 | if (ret) |
| 704 | return ret; |
| 705 | |
| 706 | return strlen(buf); |
| 707 | } |
| 708 | |
| 709 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 710 | * capability_get - Get function for sysfs attribute capability |
| 711 | * @dev: the &struct device |
| 712 | * @attr: device attributes |
| 713 | * @buf: buffer where data will be returned |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 714 | */ |
| 715 | static ssize_t capability_get(struct device *dev, |
| 716 | struct device_attribute *attr, char *buf) |
| 717 | { |
| 718 | struct mrvl_mesh_defaults defs; |
| 719 | int ret; |
| 720 | |
| 721 | ret = mesh_get_default_parameters(dev, &defs); |
| 722 | |
| 723 | if (ret) |
| 724 | return ret; |
| 725 | |
| 726 | return snprintf(buf, 5, "%d\n", defs.meshie.val.mesh_capability); |
| 727 | } |
| 728 | |
| 729 | /** |
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 730 | * capability_set - Set function for sysfs attribute capability |
| 731 | * @dev: the &struct device |
| 732 | * @attr: device attributes |
| 733 | * @buf: buffer that contains new attribute value |
| 734 | * @count: size of buffer |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 735 | */ |
| 736 | static ssize_t capability_set(struct device *dev, struct device_attribute *attr, |
| 737 | const char *buf, size_t count) |
| 738 | { |
| 739 | struct cmd_ds_mesh_config cmd; |
| 740 | struct mrvl_mesh_defaults defs; |
| 741 | struct mrvl_meshie *ie; |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 742 | struct lbs_private *priv = to_net_dev(dev)->ml_priv; |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 743 | uint32_t datum; |
| 744 | int ret; |
| 745 | |
| 746 | memset(&cmd, 0, sizeof(cmd)); |
Brian Cavagnolo | fb90490 | 2008-07-16 12:15:26 -0700 | [diff] [blame] | 747 | ret = sscanf(buf, "%d", &datum); |
| 748 | if ((ret != 1) || (datum > 255)) |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 749 | return -EINVAL; |
| 750 | |
| 751 | /* fetch all other Information Element parameters */ |
| 752 | ret = mesh_get_default_parameters(dev, &defs); |
| 753 | |
| 754 | cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie)); |
| 755 | |
| 756 | /* transfer IE elements */ |
| 757 | ie = (struct mrvl_meshie *) &cmd.data[0]; |
| 758 | memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie)); |
| 759 | /* update value */ |
| 760 | ie->val.mesh_capability = datum; |
| 761 | |
| 762 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, |
| 763 | CMD_TYPE_MESH_SET_MESH_IE); |
| 764 | if (ret) |
| 765 | return ret; |
| 766 | |
| 767 | return strlen(buf); |
| 768 | } |
| 769 | |
| 770 | |
| 771 | static DEVICE_ATTR(bootflag, 0644, bootflag_get, bootflag_set); |
| 772 | static DEVICE_ATTR(boottime, 0644, boottime_get, boottime_set); |
Javier Cardona | b679aeb | 2008-05-20 15:18:49 -0700 | [diff] [blame] | 773 | static DEVICE_ATTR(channel, 0644, channel_get, channel_set); |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 774 | static DEVICE_ATTR(mesh_id, 0644, mesh_id_get, mesh_id_set); |
| 775 | static DEVICE_ATTR(protocol_id, 0644, protocol_id_get, protocol_id_set); |
| 776 | static DEVICE_ATTR(metric_id, 0644, metric_id_get, metric_id_set); |
| 777 | static DEVICE_ATTR(capability, 0644, capability_get, capability_set); |
| 778 | |
| 779 | static struct attribute *boot_opts_attrs[] = { |
| 780 | &dev_attr_bootflag.attr, |
| 781 | &dev_attr_boottime.attr, |
Javier Cardona | b679aeb | 2008-05-20 15:18:49 -0700 | [diff] [blame] | 782 | &dev_attr_channel.attr, |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 783 | NULL |
| 784 | }; |
| 785 | |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 786 | static const struct attribute_group boot_opts_group = { |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 787 | .name = "boot_options", |
| 788 | .attrs = boot_opts_attrs, |
| 789 | }; |
| 790 | |
| 791 | static struct attribute *mesh_ie_attrs[] = { |
| 792 | &dev_attr_mesh_id.attr, |
| 793 | &dev_attr_protocol_id.attr, |
| 794 | &dev_attr_metric_id.attr, |
| 795 | &dev_attr_capability.attr, |
| 796 | NULL |
| 797 | }; |
| 798 | |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 799 | static const struct attribute_group mesh_ie_group = { |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 800 | .name = "mesh_ie", |
| 801 | .attrs = mesh_ie_attrs, |
| 802 | }; |
| 803 | |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 804 | static void lbs_persist_config_init(struct net_device *dev) |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 805 | { |
| 806 | int ret; |
| 807 | ret = sysfs_create_group(&(dev->dev.kobj), &boot_opts_group); |
| 808 | ret = sysfs_create_group(&(dev->dev.kobj), &mesh_ie_group); |
| 809 | } |
| 810 | |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 811 | static void lbs_persist_config_remove(struct net_device *dev) |
Javier Cardona | 15dbaac | 2008-05-17 21:01:24 -0700 | [diff] [blame] | 812 | { |
| 813 | sysfs_remove_group(&(dev->dev.kobj), &boot_opts_group); |
| 814 | sysfs_remove_group(&(dev->dev.kobj), &mesh_ie_group); |
| 815 | } |
Holger Schurig | c7fe64c | 2009-11-25 13:10:49 +0100 | [diff] [blame] | 816 | |
| 817 | |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 818 | /*************************************************************************** |
| 819 | * Initializing and starting, stopping mesh |
| 820 | */ |
| 821 | |
| 822 | /* |
| 823 | * Check mesh FW version and appropriately send the mesh start |
| 824 | * command |
| 825 | */ |
| 826 | int lbs_init_mesh(struct lbs_private *priv) |
| 827 | { |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 828 | int ret = 0; |
| 829 | |
| 830 | lbs_deb_enter(LBS_DEB_MESH); |
| 831 | |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 832 | /* Determine mesh_fw_ver from fwrelease and fwcapinfo */ |
| 833 | /* 5.0.16p0 9.0.0.p0 is known to NOT support any mesh */ |
| 834 | /* 5.110.22 have mesh command with 0xa3 command id */ |
| 835 | /* 10.0.0.p0 FW brings in mesh config command with different id */ |
| 836 | /* Check FW version MSB and initialize mesh_fw_ver */ |
| 837 | if (MRVL_FW_MAJOR_REV(priv->fwrelease) == MRVL_FW_V5) { |
| 838 | /* Enable mesh, if supported, and work out which TLV it uses. |
| 839 | 0x100 + 291 is an unofficial value used in 5.110.20.pXX |
| 840 | 0x100 + 37 is the official value used in 5.110.21.pXX |
| 841 | but we check them in that order because 20.pXX doesn't |
| 842 | give an error -- it just silently fails. */ |
| 843 | |
| 844 | /* 5.110.20.pXX firmware will fail the command if the channel |
| 845 | doesn't match the existing channel. But only if the TLV |
| 846 | is correct. If the channel is wrong, _BOTH_ versions will |
| 847 | give an error to 0x100+291, and allow 0x100+37 to succeed. |
| 848 | It's just that 5.110.20.pXX will not have done anything |
| 849 | useful */ |
| 850 | |
| 851 | priv->mesh_tlv = TLV_TYPE_OLD_MESH_ID; |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 852 | if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, 1)) { |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 853 | priv->mesh_tlv = TLV_TYPE_MESH_ID; |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 854 | if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, 1)) |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 855 | priv->mesh_tlv = 0; |
| 856 | } |
| 857 | } else |
| 858 | if ((MRVL_FW_MAJOR_REV(priv->fwrelease) >= MRVL_FW_V10) && |
| 859 | (priv->fwcapinfo & MESH_CAPINFO_ENABLE_MASK)) { |
| 860 | /* 10.0.0.pXX new firmwares should succeed with TLV |
| 861 | * 0x100+37; Do not invoke command with old TLV. |
| 862 | */ |
| 863 | priv->mesh_tlv = TLV_TYPE_MESH_ID; |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 864 | if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, 1)) |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 865 | priv->mesh_tlv = 0; |
| 866 | } |
| 867 | |
Daniel Drake | d931998 | 2011-07-20 17:53:56 +0100 | [diff] [blame] | 868 | /* Stop meshing until interface is brought up */ |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 869 | lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_STOP, 1); |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 870 | |
| 871 | if (priv->mesh_tlv) { |
| 872 | sprintf(priv->mesh_ssid, "mesh"); |
| 873 | priv->mesh_ssid_len = 4; |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 874 | ret = 1; |
| 875 | } |
| 876 | |
| 877 | lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret); |
| 878 | return ret; |
| 879 | } |
| 880 | |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 881 | void lbs_start_mesh(struct lbs_private *priv) |
| 882 | { |
| 883 | lbs_add_mesh(priv); |
| 884 | |
| 885 | if (device_create_file(&priv->dev->dev, &dev_attr_lbs_mesh)) |
| 886 | netdev_err(priv->dev, "cannot register lbs_mesh attribute\n"); |
| 887 | } |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 888 | |
| 889 | int lbs_deinit_mesh(struct lbs_private *priv) |
| 890 | { |
| 891 | struct net_device *dev = priv->dev; |
| 892 | int ret = 0; |
| 893 | |
| 894 | lbs_deb_enter(LBS_DEB_MESH); |
| 895 | |
| 896 | if (priv->mesh_tlv) { |
| 897 | device_remove_file(&dev->dev, &dev_attr_lbs_mesh); |
| 898 | ret = 1; |
| 899 | } |
| 900 | |
| 901 | lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret); |
| 902 | return ret; |
| 903 | } |
| 904 | |
| 905 | |
| 906 | /** |
| 907 | * lbs_mesh_stop - close the mshX interface |
| 908 | * |
| 909 | * @dev: A pointer to &net_device structure |
| 910 | * returns: 0 |
| 911 | */ |
| 912 | static int lbs_mesh_stop(struct net_device *dev) |
| 913 | { |
| 914 | struct lbs_private *priv = dev->ml_priv; |
| 915 | |
| 916 | lbs_deb_enter(LBS_DEB_MESH); |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 917 | lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_STOP, |
| 918 | lbs_mesh_get_channel(priv)); |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 919 | |
Daniel Drake | d931998 | 2011-07-20 17:53:56 +0100 | [diff] [blame] | 920 | spin_lock_irq(&priv->driver_lock); |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 921 | |
| 922 | netif_stop_queue(dev); |
| 923 | netif_carrier_off(dev); |
| 924 | |
| 925 | spin_unlock_irq(&priv->driver_lock); |
| 926 | |
| 927 | schedule_work(&priv->mcast_work); |
| 928 | |
| 929 | lbs_deb_leave(LBS_DEB_MESH); |
| 930 | return 0; |
| 931 | } |
| 932 | |
| 933 | /** |
| 934 | * lbs_mesh_dev_open - open the mshX interface |
| 935 | * |
| 936 | * @dev: A pointer to &net_device structure |
| 937 | * returns: 0 or -EBUSY if monitor mode active |
| 938 | */ |
| 939 | static int lbs_mesh_dev_open(struct net_device *dev) |
| 940 | { |
| 941 | struct lbs_private *priv = dev->ml_priv; |
| 942 | int ret = 0; |
| 943 | |
| 944 | lbs_deb_enter(LBS_DEB_NET); |
| 945 | |
| 946 | spin_lock_irq(&priv->driver_lock); |
| 947 | |
| 948 | if (priv->wdev->iftype == NL80211_IFTYPE_MONITOR) { |
| 949 | ret = -EBUSY; |
Daniel Drake | d931998 | 2011-07-20 17:53:56 +0100 | [diff] [blame] | 950 | spin_unlock_irq(&priv->driver_lock); |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 951 | goto out; |
| 952 | } |
| 953 | |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 954 | netif_carrier_on(dev); |
| 955 | |
| 956 | if (!priv->tx_pending_len) |
| 957 | netif_wake_queue(dev); |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 958 | |
| 959 | spin_unlock_irq(&priv->driver_lock); |
Daniel Drake | d931998 | 2011-07-20 17:53:56 +0100 | [diff] [blame] | 960 | |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 961 | ret = lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, |
| 962 | lbs_mesh_get_channel(priv)); |
Daniel Drake | d931998 | 2011-07-20 17:53:56 +0100 | [diff] [blame] | 963 | |
| 964 | out: |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 965 | lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret); |
| 966 | return ret; |
| 967 | } |
| 968 | |
| 969 | static const struct net_device_ops mesh_netdev_ops = { |
| 970 | .ndo_open = lbs_mesh_dev_open, |
| 971 | .ndo_stop = lbs_mesh_stop, |
| 972 | .ndo_start_xmit = lbs_hard_start_xmit, |
| 973 | .ndo_set_mac_address = lbs_set_mac_address, |
| 974 | .ndo_set_multicast_list = lbs_set_multicast_list, |
| 975 | }; |
| 976 | |
| 977 | /** |
| 978 | * lbs_add_mesh - add mshX interface |
| 979 | * |
| 980 | * @priv: A pointer to the &struct lbs_private structure |
| 981 | * returns: 0 if successful, -X otherwise |
| 982 | */ |
| 983 | static int lbs_add_mesh(struct lbs_private *priv) |
| 984 | { |
| 985 | struct net_device *mesh_dev = NULL; |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 986 | struct wireless_dev *mesh_wdev; |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 987 | int ret = 0; |
| 988 | |
| 989 | lbs_deb_enter(LBS_DEB_MESH); |
| 990 | |
| 991 | /* Allocate a virtual mesh device */ |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 992 | mesh_wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); |
| 993 | if (!mesh_wdev) { |
| 994 | lbs_deb_mesh("init mshX wireless device failed\n"); |
| 995 | ret = -ENOMEM; |
| 996 | goto done; |
| 997 | } |
| 998 | |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 999 | mesh_dev = alloc_netdev(0, "msh%d", ether_setup); |
| 1000 | if (!mesh_dev) { |
| 1001 | lbs_deb_mesh("init mshX device failed\n"); |
| 1002 | ret = -ENOMEM; |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 1003 | goto err_free_wdev; |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 1004 | } |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 1005 | |
| 1006 | mesh_wdev->iftype = NL80211_IFTYPE_MESH_POINT; |
| 1007 | mesh_wdev->wiphy = priv->wdev->wiphy; |
| 1008 | mesh_wdev->netdev = mesh_dev; |
| 1009 | |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 1010 | mesh_dev->ml_priv = priv; |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 1011 | mesh_dev->ieee80211_ptr = mesh_wdev; |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 1012 | priv->mesh_dev = mesh_dev; |
| 1013 | |
| 1014 | mesh_dev->netdev_ops = &mesh_netdev_ops; |
| 1015 | mesh_dev->ethtool_ops = &lbs_ethtool_ops; |
| 1016 | memcpy(mesh_dev->dev_addr, priv->dev->dev_addr, ETH_ALEN); |
| 1017 | |
| 1018 | SET_NETDEV_DEV(priv->mesh_dev, priv->dev->dev.parent); |
| 1019 | |
| 1020 | mesh_dev->flags |= IFF_BROADCAST | IFF_MULTICAST; |
| 1021 | /* Register virtual mesh interface */ |
| 1022 | ret = register_netdev(mesh_dev); |
| 1023 | if (ret) { |
| 1024 | pr_err("cannot register mshX virtual interface\n"); |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 1025 | goto err_free_netdev; |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 1026 | } |
| 1027 | |
| 1028 | ret = sysfs_create_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group); |
| 1029 | if (ret) |
| 1030 | goto err_unregister; |
| 1031 | |
| 1032 | lbs_persist_config_init(mesh_dev); |
| 1033 | |
| 1034 | /* Everything successful */ |
| 1035 | ret = 0; |
| 1036 | goto done; |
| 1037 | |
| 1038 | err_unregister: |
| 1039 | unregister_netdev(mesh_dev); |
| 1040 | |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 1041 | err_free_netdev: |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 1042 | free_netdev(mesh_dev); |
| 1043 | |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 1044 | err_free_wdev: |
| 1045 | kfree(mesh_wdev); |
| 1046 | |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 1047 | done: |
| 1048 | lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret); |
| 1049 | return ret; |
| 1050 | } |
| 1051 | |
| 1052 | void lbs_remove_mesh(struct lbs_private *priv) |
| 1053 | { |
| 1054 | struct net_device *mesh_dev; |
| 1055 | |
| 1056 | mesh_dev = priv->mesh_dev; |
| 1057 | if (!mesh_dev) |
| 1058 | return; |
| 1059 | |
| 1060 | lbs_deb_enter(LBS_DEB_MESH); |
| 1061 | netif_stop_queue(mesh_dev); |
| 1062 | netif_carrier_off(mesh_dev); |
| 1063 | sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group); |
| 1064 | lbs_persist_config_remove(mesh_dev); |
| 1065 | unregister_netdev(mesh_dev); |
| 1066 | priv->mesh_dev = NULL; |
Daniel Drake | 49fee69 | 2011-07-21 20:43:17 +0100 | [diff] [blame^] | 1067 | kfree(mesh_dev->ieee80211_ptr); |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 1068 | free_netdev(mesh_dev); |
| 1069 | lbs_deb_leave(LBS_DEB_MESH); |
| 1070 | } |
| 1071 | |
| 1072 | |
| 1073 | /*************************************************************************** |
| 1074 | * Sending and receiving |
| 1075 | */ |
| 1076 | struct net_device *lbs_mesh_set_dev(struct lbs_private *priv, |
| 1077 | struct net_device *dev, struct rxpd *rxpd) |
| 1078 | { |
| 1079 | if (priv->mesh_dev) { |
| 1080 | if (priv->mesh_tlv == TLV_TYPE_OLD_MESH_ID) { |
| 1081 | if (rxpd->rx_control & RxPD_MESH_FRAME) |
| 1082 | dev = priv->mesh_dev; |
| 1083 | } else if (priv->mesh_tlv == TLV_TYPE_MESH_ID) { |
| 1084 | if (rxpd->u.bss.bss_num == MESH_IFACE_ID) |
| 1085 | dev = priv->mesh_dev; |
| 1086 | } |
| 1087 | } |
| 1088 | return dev; |
| 1089 | } |
| 1090 | |
| 1091 | |
| 1092 | void lbs_mesh_set_txpd(struct lbs_private *priv, |
| 1093 | struct net_device *dev, struct txpd *txpd) |
| 1094 | { |
| 1095 | if (dev == priv->mesh_dev) { |
| 1096 | if (priv->mesh_tlv == TLV_TYPE_OLD_MESH_ID) |
| 1097 | txpd->tx_control |= cpu_to_le32(TxPD_MESH_FRAME); |
| 1098 | else if (priv->mesh_tlv == TLV_TYPE_MESH_ID) |
| 1099 | txpd->u.bss.bss_num = MESH_IFACE_ID; |
| 1100 | } |
| 1101 | } |
| 1102 | |
Holger Schurig | c7fe64c | 2009-11-25 13:10:49 +0100 | [diff] [blame] | 1103 | |
| 1104 | /*************************************************************************** |
| 1105 | * Ethtool related |
| 1106 | */ |
| 1107 | |
Daniel Drake | 3db4f98 | 2011-07-20 17:53:50 +0100 | [diff] [blame] | 1108 | static const char * const mesh_stat_strings[] = { |
Holger Schurig | c7fe64c | 2009-11-25 13:10:49 +0100 | [diff] [blame] | 1109 | "drop_duplicate_bcast", |
| 1110 | "drop_ttl_zero", |
| 1111 | "drop_no_fwd_route", |
| 1112 | "drop_no_buffers", |
| 1113 | "fwded_unicast_cnt", |
| 1114 | "fwded_bcast_cnt", |
| 1115 | "drop_blind_table", |
| 1116 | "tx_failed_cnt" |
| 1117 | }; |
| 1118 | |
| 1119 | void lbs_mesh_ethtool_get_stats(struct net_device *dev, |
| 1120 | struct ethtool_stats *stats, uint64_t *data) |
| 1121 | { |
| 1122 | struct lbs_private *priv = dev->ml_priv; |
| 1123 | struct cmd_ds_mesh_access mesh_access; |
| 1124 | int ret; |
| 1125 | |
| 1126 | lbs_deb_enter(LBS_DEB_ETHTOOL); |
| 1127 | |
| 1128 | /* Get Mesh Statistics */ |
| 1129 | ret = lbs_mesh_access(priv, CMD_ACT_MESH_GET_STATS, &mesh_access); |
| 1130 | |
| 1131 | if (ret) { |
| 1132 | memset(data, 0, MESH_STATS_NUM*(sizeof(uint64_t))); |
| 1133 | return; |
| 1134 | } |
| 1135 | |
| 1136 | priv->mstats.fwd_drop_rbt = le32_to_cpu(mesh_access.data[0]); |
| 1137 | priv->mstats.fwd_drop_ttl = le32_to_cpu(mesh_access.data[1]); |
| 1138 | priv->mstats.fwd_drop_noroute = le32_to_cpu(mesh_access.data[2]); |
| 1139 | priv->mstats.fwd_drop_nobuf = le32_to_cpu(mesh_access.data[3]); |
| 1140 | priv->mstats.fwd_unicast_cnt = le32_to_cpu(mesh_access.data[4]); |
| 1141 | priv->mstats.fwd_bcast_cnt = le32_to_cpu(mesh_access.data[5]); |
| 1142 | priv->mstats.drop_blind = le32_to_cpu(mesh_access.data[6]); |
| 1143 | priv->mstats.tx_failed_cnt = le32_to_cpu(mesh_access.data[7]); |
| 1144 | |
| 1145 | data[0] = priv->mstats.fwd_drop_rbt; |
| 1146 | data[1] = priv->mstats.fwd_drop_ttl; |
| 1147 | data[2] = priv->mstats.fwd_drop_noroute; |
| 1148 | data[3] = priv->mstats.fwd_drop_nobuf; |
| 1149 | data[4] = priv->mstats.fwd_unicast_cnt; |
| 1150 | data[5] = priv->mstats.fwd_bcast_cnt; |
| 1151 | data[6] = priv->mstats.drop_blind; |
| 1152 | data[7] = priv->mstats.tx_failed_cnt; |
| 1153 | |
| 1154 | lbs_deb_enter(LBS_DEB_ETHTOOL); |
| 1155 | } |
| 1156 | |
| 1157 | int lbs_mesh_ethtool_get_sset_count(struct net_device *dev, int sset) |
| 1158 | { |
| 1159 | struct lbs_private *priv = dev->ml_priv; |
| 1160 | |
| 1161 | if (sset == ETH_SS_STATS && dev == priv->mesh_dev) |
| 1162 | return MESH_STATS_NUM; |
| 1163 | |
| 1164 | return -EOPNOTSUPP; |
| 1165 | } |
| 1166 | |
| 1167 | void lbs_mesh_ethtool_get_strings(struct net_device *dev, |
| 1168 | uint32_t stringset, uint8_t *s) |
| 1169 | { |
| 1170 | int i; |
| 1171 | |
| 1172 | lbs_deb_enter(LBS_DEB_ETHTOOL); |
| 1173 | |
| 1174 | switch (stringset) { |
| 1175 | case ETH_SS_STATS: |
| 1176 | for (i = 0; i < MESH_STATS_NUM; i++) { |
| 1177 | memcpy(s + i * ETH_GSTRING_LEN, |
| 1178 | mesh_stat_strings[i], |
| 1179 | ETH_GSTRING_LEN); |
| 1180 | } |
| 1181 | break; |
| 1182 | } |
| 1183 | lbs_deb_enter(LBS_DEB_ETHTOOL); |
| 1184 | } |