2 * This file contains ioctl functions
5 #include <linux/ctype.h>
6 #include <linux/delay.h>
8 #include <linux/if_arp.h>
9 #include <linux/wireless.h>
11 #include <net/iw_handler.h>
12 #include <net/ieee80211.h>
22 #define MAX_SCAN_CELL_SIZE (IW_EV_ADDR_LEN + \
24 IW_EV_UINT_LEN + IW_EV_FREQ_LEN + \
25 IW_EV_QUAL_LEN + IW_ESSID_MAX_SIZE + \
26 IW_EV_PARAM_LEN + 40) /* 40 for WPAIE */
28 #define WAIT_FOR_SCAN_RRESULT_MAX_TIME (10 * HZ)
30 static int wlan_set_region(wlan_private * priv, u16 region_code)
34 for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
35 // use the region code to search for the index
36 if (region_code == libertas_region_code_to_index[i]) {
37 priv->adapter->regiontableindex = (u16) i;
38 priv->adapter->regioncode = region_code;
43 // if it's unidentified region code
44 if (i >= MRVDRV_MAX_REGION_CODE) {
45 lbs_pr_debug(1, "region Code not identified\n");
50 if (libertas_set_regiontable(priv, priv->adapter->regioncode, 0)) {
58 static inline int hex2int(char c)
60 if (c >= '0' && c <= '9')
62 if (c >= 'a' && c <= 'f')
63 return (c - 'a' + 10);
64 if (c >= 'A' && c <= 'F')
65 return (c - 'A' + 10);
69 /* Convert a string representation of a MAC address ("xx:xx:xx:xx:xx:xx")
70 into binary format (6 bytes).
72 This function expects that each byte is represented with 2 characters
73 (e.g., 11:2:11:11:11:11 is invalid)
76 static char *eth_str2addr(char *ethstr, u8 * addr)
81 /* get rid of initial blanks */
82 while (*pos == ' ' || *pos == '\t')
85 for (i = 0; i < 6; i++) {
86 val = hex2int(*pos++);
89 val2 = hex2int(*pos++);
92 addr[i] = (val * 16 + val2) & 0xff;
94 if (i < 5 && *pos++ != ':')
100 /* this writes xx:xx:xx:xx:xx:xx into ethstr
101 (ethstr must have space for 18 chars) */
102 static int eth_addr2str(u8 * addr, char *ethstr)
107 for (i = 0; i < 6; i++) {
108 sprintf(pos, "%02x", addr[i] & 0xff);
117 * @brief Add an entry to the BT table
118 * @param priv A pointer to wlan_private structure
119 * @param req A pointer to ifreq structure
120 * @return 0 --success, otherwise fail
122 static int wlan_bt_add_ioctl(wlan_private * priv, struct ifreq *req)
124 struct iwreq *wrq = (struct iwreq *)req;
125 char ethaddrs_str[18];
127 u8 ethaddr[ETH_ALEN];
130 if (copy_from_user(ethaddrs_str, wrq->u.data.pointer,
131 sizeof(ethaddrs_str)))
134 if ((pos = eth_str2addr(ethaddrs_str, ethaddr)) == NULL) {
135 lbs_pr_info("BT_ADD: Invalid MAC address\n");
139 lbs_pr_debug(1, "BT: adding %s\n", ethaddrs_str);
141 return (libertas_prepare_and_send_command(priv, cmd_bt_access,
142 cmd_act_bt_access_add,
143 cmd_option_waitforrsp, 0, ethaddr));
147 * @brief Delete an entry from the BT table
148 * @param priv A pointer to wlan_private structure
149 * @param req A pointer to ifreq structure
150 * @return 0 --success, otherwise fail
152 static int wlan_bt_del_ioctl(wlan_private * priv, struct ifreq *req)
154 struct iwreq *wrq = (struct iwreq *)req;
155 char ethaddrs_str[18];
156 u8 ethaddr[ETH_ALEN];
160 if (copy_from_user(ethaddrs_str, wrq->u.data.pointer,
161 sizeof(ethaddrs_str)))
164 if ((pos = eth_str2addr(ethaddrs_str, ethaddr)) == NULL) {
165 lbs_pr_info("Invalid MAC address\n");
169 lbs_pr_debug(1, "BT: deleting %s\n", ethaddrs_str);
171 return (libertas_prepare_and_send_command(priv,
173 cmd_act_bt_access_del,
174 cmd_option_waitforrsp, 0, ethaddr));
180 * @brief Reset all entries from the BT table
181 * @param priv A pointer to wlan_private structure
182 * @return 0 --success, otherwise fail
184 static int wlan_bt_reset_ioctl(wlan_private * priv)
188 lbs_pr_alert( "BT: resetting\n");
190 return (libertas_prepare_and_send_command(priv,
192 cmd_act_bt_access_reset,
193 cmd_option_waitforrsp, 0, NULL));
200 * @brief List an entry from the BT table
201 * @param priv A pointer to wlan_private structure
202 * @param req A pointer to ifreq structure
203 * @return 0 --success, otherwise fail
205 static int wlan_bt_list_ioctl(wlan_private * priv, struct ifreq *req)
209 struct iwreq *wrq = (struct iwreq *)req;
210 /* used to pass id and store the bt entry returned by the FW */
213 char addr1addr2[2 * ETH_ALEN];
215 static char outstr[64];
221 if (copy_from_user(outstr, wrq->u.data.pointer, sizeof(outstr))) {
222 lbs_pr_debug(1, "Copy from user failed\n");
225 param.id = simple_strtoul(outstr, NULL, 10);
226 pos = sprintf(pbuf, "%d: ", param.id);
229 ret = libertas_prepare_and_send_command(priv, cmd_bt_access,
230 cmd_act_bt_access_list,
231 cmd_option_waitforrsp, 0,
235 addr1 = param.addr1addr2;
237 pos = sprintf(pbuf, "ignoring traffic from ");
239 pos = eth_addr2str(addr1, pbuf);
242 sprintf(pbuf, "(null)");
246 wrq->u.data.length = strlen(outstr);
247 if (copy_to_user(wrq->u.data.pointer, (char *)outstr,
248 wrq->u.data.length)) {
249 lbs_pr_debug(1, "BT_LIST: Copy to user failed!\n");
258 * @brief Find the next parameter in an input string
259 * @param ptr A pointer to the input parameter string
260 * @return A pointer to the next parameter, or 0 if no parameters left.
262 static char * next_param(char * ptr)
264 if (!ptr) return NULL;
265 while (*ptr == ' ' || *ptr == '\t') ++ptr;
266 return (*ptr == '\0') ? NULL : ptr;
270 * @brief Add an entry to the FWT table
271 * @param priv A pointer to wlan_private structure
272 * @param req A pointer to ifreq structure
273 * @return 0 --success, otherwise fail
275 static int wlan_fwt_add_ioctl(wlan_private * priv, struct ifreq *req)
277 struct iwreq *wrq = (struct iwreq *)req;
279 static struct cmd_ds_fwt_access fwt_access;
283 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str)))
286 if ((ptr = eth_str2addr(in_str, fwt_access.da)) == NULL) {
287 lbs_pr_alert( "FWT_ADD: Invalid MAC address 1\n");
291 if ((ptr = eth_str2addr(ptr, fwt_access.ra)) == NULL) {
292 lbs_pr_alert( "FWT_ADD: Invalid MAC address 2\n");
296 if ((ptr = next_param(ptr)))
298 cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
300 fwt_access.metric = FWT_DEFAULT_METRIC;
302 if ((ptr = next_param(ptr)))
303 fwt_access.dir = (u8)simple_strtoul(ptr, &ptr, 10);
305 fwt_access.dir = FWT_DEFAULT_DIR;
307 if ((ptr = next_param(ptr)))
309 cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
311 fwt_access.ssn = FWT_DEFAULT_SSN;
313 if ((ptr = next_param(ptr)))
315 cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
317 fwt_access.dsn = FWT_DEFAULT_DSN;
319 if ((ptr = next_param(ptr)))
320 fwt_access.hopcount = simple_strtoul(ptr, &ptr, 10);
322 fwt_access.hopcount = FWT_DEFAULT_HOPCOUNT;
324 if ((ptr = next_param(ptr)))
325 fwt_access.ttl = simple_strtoul(ptr, &ptr, 10);
327 fwt_access.ttl = FWT_DEFAULT_TTL;
329 if ((ptr = next_param(ptr)))
330 fwt_access.expiration =
331 cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
333 fwt_access.expiration = FWT_DEFAULT_EXPIRATION;
335 if ((ptr = next_param(ptr)))
336 fwt_access.sleepmode = (u8)simple_strtoul(ptr, &ptr, 10);
338 fwt_access.sleepmode = FWT_DEFAULT_SLEEPMODE;
340 if ((ptr = next_param(ptr)))
342 cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
344 fwt_access.snr = FWT_DEFAULT_SNR;
348 char ethaddr1_str[18], ethaddr2_str[18];
349 eth_addr2str(fwt_access.da, ethaddr1_str);
350 eth_addr2str(fwt_access.ra, ethaddr2_str);
351 lbs_pr_debug(1, "FWT_ADD: adding (da:%s,%i,ra:%s)\n", ethaddr1_str,
352 fwt_access.dir, ethaddr2_str);
353 lbs_pr_debug(1, "FWT_ADD: ssn:%u dsn:%u met:%u hop:%u ttl:%u exp:%u slp:%u snr:%u\n",
354 fwt_access.ssn, fwt_access.dsn, fwt_access.metric,
355 fwt_access.hopcount, fwt_access.ttl, fwt_access.expiration,
356 fwt_access.sleepmode, fwt_access.snr);
361 return (libertas_prepare_and_send_command(priv, cmd_fwt_access,
362 cmd_act_fwt_access_add,
363 cmd_option_waitforrsp, 0,
364 (void *)&fwt_access));
368 * @brief Delete an entry from the FWT table
369 * @param priv A pointer to wlan_private structure
370 * @param req A pointer to ifreq structure
371 * @return 0 --success, otherwise fail
373 static int wlan_fwt_del_ioctl(wlan_private * priv, struct ifreq *req)
375 struct iwreq *wrq = (struct iwreq *)req;
377 static struct cmd_ds_fwt_access fwt_access;
381 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str)))
384 if ((ptr = eth_str2addr(in_str, fwt_access.da)) == NULL) {
385 lbs_pr_alert( "FWT_DEL: Invalid MAC address 1\n");
389 if ((ptr = eth_str2addr(ptr, fwt_access.ra)) == NULL) {
390 lbs_pr_alert( "FWT_DEL: Invalid MAC address 2\n");
394 if ((ptr = next_param(ptr)))
395 fwt_access.dir = (u8)simple_strtoul(ptr, &ptr, 10);
397 fwt_access.dir = FWT_DEFAULT_DIR;
401 char ethaddr1_str[18], ethaddr2_str[18];
402 lbs_pr_debug(1, "FWT_DEL: line is %s\n", in_str);
403 eth_addr2str(fwt_access.da, ethaddr1_str);
404 eth_addr2str(fwt_access.ra, ethaddr2_str);
405 lbs_pr_debug(1, "FWT_DEL: removing (da:%s,ra:%s,dir:%d)\n", ethaddr1_str,
406 ethaddr2_str, fwt_access.dir);
411 return (libertas_prepare_and_send_command(priv,
413 cmd_act_fwt_access_del,
414 cmd_option_waitforrsp, 0,
415 (void *)&fwt_access));
420 * @brief Print route parameters
421 * @param fwt_access struct cmd_ds_fwt_access with route info
422 * @param buf destination buffer for route info
424 static void print_route(struct cmd_ds_fwt_access fwt_access, char *buf)
426 buf += sprintf(buf, " ");
427 buf += eth_addr2str(fwt_access.da, buf);
428 buf += sprintf(buf, " ");
429 buf += eth_addr2str(fwt_access.ra, buf);
430 buf += sprintf(buf, " %u", le32_to_cpu(fwt_access.metric));
431 buf += sprintf(buf, " %u", fwt_access.dir);
432 buf += sprintf(buf, " %u", le32_to_cpu(fwt_access.ssn));
433 buf += sprintf(buf, " %u", le32_to_cpu(fwt_access.dsn));
434 buf += sprintf(buf, " %u", fwt_access.hopcount);
435 buf += sprintf(buf, " %u", fwt_access.ttl);
436 buf += sprintf(buf, " %u", le32_to_cpu(fwt_access.expiration));
437 buf += sprintf(buf, " %u", fwt_access.sleepmode);
438 buf += sprintf(buf, " %u", le32_to_cpu(fwt_access.snr));
442 * @brief Lookup an entry in the FWT table
443 * @param priv A pointer to wlan_private structure
444 * @param req A pointer to ifreq structure
445 * @return 0 --success, otherwise fail
447 static int wlan_fwt_lookup_ioctl(wlan_private * priv, struct ifreq *req)
449 struct iwreq *wrq = (struct iwreq *)req;
452 static struct cmd_ds_fwt_access fwt_access;
453 static char out_str[128];
457 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str)))
460 if ((ptr = eth_str2addr(in_str, fwt_access.da)) == NULL) {
461 lbs_pr_alert( "FWT_LOOKUP: Invalid MAC address\n");
467 char ethaddr1_str[18];
468 lbs_pr_debug(1, "FWT_LOOKUP: line is %s\n", in_str);
469 eth_addr2str(fwt_access.da, ethaddr1_str);
470 lbs_pr_debug(1, "FWT_LOOKUP: looking for (da:%s)\n", ethaddr1_str);
474 ret = libertas_prepare_and_send_command(priv,
476 cmd_act_fwt_access_lookup,
477 cmd_option_waitforrsp, 0,
478 (void *)&fwt_access);
481 print_route(fwt_access, out_str);
483 sprintf(out_str, "(null)");
485 wrq->u.data.length = strlen(out_str);
486 if (copy_to_user(wrq->u.data.pointer, (char *)out_str,
487 wrq->u.data.length)) {
488 lbs_pr_debug(1, "FWT_LOOKUP: Copy to user failed!\n");
497 * @brief Reset all entries from the FWT table
498 * @param priv A pointer to wlan_private structure
499 * @return 0 --success, otherwise fail
501 static int wlan_fwt_reset_ioctl(wlan_private * priv)
503 lbs_pr_debug(1, "FWT: resetting\n");
505 return (libertas_prepare_and_send_command(priv,
507 cmd_act_fwt_access_reset,
508 cmd_option_waitforrsp, 0, NULL));
512 * @brief List an entry from the FWT table
513 * @param priv A pointer to wlan_private structure
514 * @param req A pointer to ifreq structure
515 * @return 0 --success, otherwise fail
517 static int wlan_fwt_list_ioctl(wlan_private * priv, struct ifreq *req)
519 struct iwreq *wrq = (struct iwreq *)req;
521 static struct cmd_ds_fwt_access fwt_access;
523 static char out_str[128];
524 char *pbuf = out_str;
528 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str)))
531 fwt_access.id = cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
535 lbs_pr_debug(1, "FWT_LIST: line is %s\n", in_str);
536 lbs_pr_debug(1, "FWT_LIST: listing id:%i\n", le32_to_cpu(fwt_access.id));
540 ret = libertas_prepare_and_send_command(priv, cmd_fwt_access,
541 cmd_act_fwt_access_list,
542 cmd_option_waitforrsp, 0, (void *)&fwt_access);
545 print_route(fwt_access, pbuf);
547 pbuf += sprintf(pbuf, " (null)");
549 wrq->u.data.length = strlen(out_str);
550 if (copy_to_user(wrq->u.data.pointer, (char *)out_str,
551 wrq->u.data.length)) {
552 lbs_pr_debug(1, "FWT_LIST: Copy to user failed!\n");
561 * @brief List an entry from the FRT table
562 * @param priv A pointer to wlan_private structure
563 * @param req A pointer to ifreq structure
564 * @return 0 --success, otherwise fail
566 static int wlan_fwt_list_route_ioctl(wlan_private * priv, struct ifreq *req)
568 struct iwreq *wrq = (struct iwreq *)req;
570 static struct cmd_ds_fwt_access fwt_access;
572 static char out_str[128];
573 char *pbuf = out_str;
577 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str)))
580 fwt_access.id = cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
584 lbs_pr_debug(1, "FWT_LIST_ROUTE: line is %s\n", in_str);
585 lbs_pr_debug(1, "FWT_LIST_ROUTE: listing id:%i\n", le32_to_cpu(fwt_access.id));
589 ret = libertas_prepare_and_send_command(priv, cmd_fwt_access,
590 cmd_act_fwt_access_list_route,
591 cmd_option_waitforrsp, 0, (void *)&fwt_access);
594 pbuf += sprintf(pbuf, " ");
595 pbuf += eth_addr2str(fwt_access.da, pbuf);
596 pbuf += sprintf(pbuf, " %u", le32_to_cpu(fwt_access.metric));
597 pbuf += sprintf(pbuf, " %u", fwt_access.dir);
598 /* note that the firmware returns the nid in the id field */
599 pbuf += sprintf(pbuf, " %u", le32_to_cpu(fwt_access.id));
600 pbuf += sprintf(pbuf, " %u", le32_to_cpu(fwt_access.ssn));
601 pbuf += sprintf(pbuf, " %u", le32_to_cpu(fwt_access.dsn));
602 pbuf += sprintf(pbuf, " hop %u", fwt_access.hopcount);
603 pbuf += sprintf(pbuf, " ttl %u", fwt_access.ttl);
604 pbuf += sprintf(pbuf, " %u", le32_to_cpu(fwt_access.expiration));
606 pbuf += sprintf(pbuf, " (null)");
608 wrq->u.data.length = strlen(out_str);
609 if (copy_to_user(wrq->u.data.pointer, (char *)out_str,
610 wrq->u.data.length)) {
611 lbs_pr_debug(1, "FWT_LIST_ROUTE: Copy to user failed!\n");
620 * @brief List an entry from the FNT table
621 * @param priv A pointer to wlan_private structure
622 * @param req A pointer to ifreq structure
623 * @return 0 --success, otherwise fail
625 static int wlan_fwt_list_neighbor_ioctl(wlan_private * priv, struct ifreq *req)
627 struct iwreq *wrq = (struct iwreq *)req;
629 static struct cmd_ds_fwt_access fwt_access;
631 static char out_str[128];
632 char *pbuf = out_str;
636 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str)))
639 memset(&fwt_access, 0, sizeof(fwt_access));
640 fwt_access.id = cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
644 lbs_pr_debug(1, "FWT_LIST_NEIGHBOR: line is %s\n", in_str);
645 lbs_pr_debug(1, "FWT_LIST_NEIGHBOR: listing id:%i\n", le32_to_cpu(fwt_access.id));
649 ret = libertas_prepare_and_send_command(priv, cmd_fwt_access,
650 cmd_act_fwt_access_list_neighbor,
651 cmd_option_waitforrsp, 0,
652 (void *)&fwt_access);
655 pbuf += sprintf(pbuf, " ra ");
656 pbuf += eth_addr2str(fwt_access.ra, pbuf);
657 pbuf += sprintf(pbuf, " slp %u", fwt_access.sleepmode);
658 pbuf += sprintf(pbuf, " snr %u", le32_to_cpu(fwt_access.snr));
659 pbuf += sprintf(pbuf, " ref %u", le32_to_cpu(fwt_access.references));
661 pbuf += sprintf(pbuf, " (null)");
663 wrq->u.data.length = strlen(out_str);
664 if (copy_to_user(wrq->u.data.pointer, (char *)out_str,
665 wrq->u.data.length)) {
666 lbs_pr_debug(1, "FWT_LIST_NEIGHBOR: Copy to user failed!\n");
675 * @brief Cleans up the route (FRT) and neighbor (FNT) tables
676 * (Garbage Collection)
677 * @param priv A pointer to wlan_private structure
678 * @param req A pointer to ifreq structure
679 * @return 0 --success, otherwise fail
681 static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req)
683 struct iwreq *wrq = (struct iwreq *)req;
684 static struct cmd_ds_fwt_access fwt_access;
689 lbs_pr_debug(1, "FWT: cleaning up\n");
691 memset(&fwt_access, 0, sizeof(fwt_access));
693 ret = libertas_prepare_and_send_command(priv, cmd_fwt_access,
694 cmd_act_fwt_access_cleanup,
695 cmd_option_waitforrsp, 0,
696 (void *)&fwt_access);
699 wrq->u.param.value = le32_to_cpu(fwt_access.references);
708 * @brief Gets firmware internal time (debug purposes)
709 * @param priv A pointer to wlan_private structure
710 * @param req A pointer to ifreq structure
711 * @return 0 --success, otherwise fail
713 static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req)
715 struct iwreq *wrq = (struct iwreq *)req;
716 static struct cmd_ds_fwt_access fwt_access;
721 lbs_pr_debug(1, "FWT: getting time\n");
723 memset(&fwt_access, 0, sizeof(fwt_access));
725 ret = libertas_prepare_and_send_command(priv, cmd_fwt_access,
726 cmd_act_fwt_access_time,
727 cmd_option_waitforrsp, 0,
728 (void *)&fwt_access);
731 wrq->u.param.value = le32_to_cpu(fwt_access.references);
740 * @brief Gets mesh ttl from firmware
741 * @param priv A pointer to wlan_private structure
742 * @param req A pointer to ifreq structure
743 * @return 0 --success, otherwise fail
745 static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req)
747 struct iwreq *wrq = (struct iwreq *)req;
748 struct cmd_ds_mesh_access mesh_access;
753 memset(&mesh_access, 0, sizeof(mesh_access));
755 ret = libertas_prepare_and_send_command(priv, cmd_mesh_access,
756 cmd_act_mesh_get_ttl,
757 cmd_option_waitforrsp, 0,
758 (void *)&mesh_access);
761 wrq->u.param.value = le32_to_cpu(mesh_access.data[0]);
770 * @brief Gets mesh ttl from firmware
771 * @param priv A pointer to wlan_private structure
772 * @param ttl New ttl value
773 * @return 0 --success, otherwise fail
775 static int wlan_mesh_set_ttl_ioctl(wlan_private * priv, int ttl)
777 struct cmd_ds_mesh_access mesh_access;
782 if( (ttl > 0xff) || (ttl < 0) )
785 memset(&mesh_access, 0, sizeof(mesh_access));
786 mesh_access.data[0] = ttl;
788 ret = libertas_prepare_and_send_command(priv, cmd_mesh_access,
789 cmd_act_mesh_set_ttl,
790 cmd_option_waitforrsp, 0,
791 (void *)&mesh_access);
801 * @brief ioctl function - entry point
803 * @param dev A pointer to net_device structure
804 * @param req A pointer to ifreq structure
806 * @return 0--success, otherwise fail
808 int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
814 wlan_private *priv = dev->priv;
815 wlan_adapter *adapter = priv->adapter;
816 struct iwreq *wrq = (struct iwreq *)req;
820 lbs_pr_debug(1, "libertas_do_ioctl: ioctl cmd = 0x%x\n", cmd);
822 case WLAN_SETNONE_GETNONE: /* set WPA mode on/off ioctl #20 */
823 switch (wrq->u.data.flags) {
824 case WLAN_SUBCMD_BT_RESET: /* bt_reset */
825 wlan_bt_reset_ioctl(priv);
827 case WLAN_SUBCMD_FWT_RESET: /* fwt_reset */
828 wlan_fwt_reset_ioctl(priv);
830 } /* End of switch */
833 case WLAN_SETONEINT_GETNONE:
834 /* The first 4 bytes of req->ifr_data is sub-ioctl number
835 * after 4 bytes sits the payload.
837 subcmd = wrq->u.data.flags;
839 subcmd = (int)wrq->u.param.value;
843 idata = SUBCMD_DATA(wrq);
844 ret = wlan_set_region(priv, (u16) idata);
846 case WLAN_SUBCMD_MESH_SET_TTL:
847 idata = SUBCMD_DATA(wrq);
848 ret = wlan_mesh_set_ttl_ioctl(priv, idata);
858 case WLAN_SET128CHAR_GET128CHAR:
859 switch ((int)wrq->u.data.flags) {
860 case WLAN_SUBCMD_BT_ADD:
861 ret = wlan_bt_add_ioctl(priv, req);
863 case WLAN_SUBCMD_BT_DEL:
864 ret = wlan_bt_del_ioctl(priv, req);
866 case WLAN_SUBCMD_BT_LIST:
867 ret = wlan_bt_list_ioctl(priv, req);
869 case WLAN_SUBCMD_FWT_ADD:
870 ret = wlan_fwt_add_ioctl(priv, req);
872 case WLAN_SUBCMD_FWT_DEL:
873 ret = wlan_fwt_del_ioctl(priv, req);
875 case WLAN_SUBCMD_FWT_LOOKUP:
876 ret = wlan_fwt_lookup_ioctl(priv, req);
878 case WLAN_SUBCMD_FWT_LIST_NEIGHBOR:
879 ret = wlan_fwt_list_neighbor_ioctl(priv, req);
881 case WLAN_SUBCMD_FWT_LIST:
882 ret = wlan_fwt_list_ioctl(priv, req);
884 case WLAN_SUBCMD_FWT_LIST_ROUTE:
885 ret = wlan_fwt_list_route_ioctl(priv, req);
890 case WLAN_SETNONE_GETONEINT:
891 switch (wrq->u.param.value) {
893 pdata = (int *)wrq->u.name;
894 *pdata = (int)adapter->regioncode;
896 case WLAN_SUBCMD_FWT_CLEANUP: /* fwt_cleanup */
897 ret = wlan_fwt_cleanup_ioctl(priv, req);
900 case WLAN_SUBCMD_FWT_TIME: /* fwt_time */
901 ret = wlan_fwt_time_ioctl(priv, req);
904 case WLAN_SUBCMD_MESH_GET_TTL:
905 ret = wlan_mesh_get_ttl_ioctl(priv, req);
915 case WLAN_SET_GET_SIXTEEN_INT:
916 switch ((int)wrq->u.data.flags) {
917 case WLAN_LED_GPIO_CTRL:
922 struct cmd_ds_802_11_led_ctrl ctrl;
923 struct mrvlietypes_ledgpio *gpio =
924 (struct mrvlietypes_ledgpio *) ctrl.data;
926 memset(&ctrl, 0, sizeof(ctrl));
927 if (wrq->u.data.length > MAX_LEDS * 2)
929 if ((wrq->u.data.length % 2) != 0)
931 if (wrq->u.data.length == 0) {
937 (data, wrq->u.data.pointer,
939 wrq->u.data.length)) {
941 "Copy from user failed\n");
948 ctrl.numled = cpu_to_le16(0);
950 cpu_to_le16(TLV_TYPE_LED_GPIO);
951 gpio->header.len = wrq->u.data.length;
952 for (i = 0; i < wrq->u.data.length;
954 gpio->ledpin[i / 2].led =
956 gpio->ledpin[i / 2].pin =
961 libertas_prepare_and_send_command(priv,
962 cmd_802_11_led_gpio_ctrl,
964 cmd_option_waitforrsp,
966 for (i = 0; i < gpio->header.len; i += 2) {
967 data[i] = gpio->ledpin[i / 2].led;
968 data[i + 1] = gpio->ledpin[i / 2].pin;
970 if (copy_to_user(wrq->u.data.pointer, data,
973 lbs_pr_debug(1, "Copy to user failed\n");
977 wrq->u.data.length = gpio->header.len;