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)
35 for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
36 // use the region code to search for the index
37 if (region_code == libertas_region_code_to_index[i]) {
38 priv->adapter->regiontableindex = (u16) i;
39 priv->adapter->regioncode = region_code;
44 // if it's unidentified region code
45 if (i >= MRVDRV_MAX_REGION_CODE) {
46 lbs_deb_ioctl("region Code not identified\n");
51 if (libertas_set_regiontable(priv, priv->adapter->regioncode, 0)) {
56 lbs_deb_leave_args(LBS_DEB_IOCTL, "ret %d", ret);
60 static inline int hex2int(char c)
62 if (c >= '0' && c <= '9')
64 if (c >= 'a' && c <= 'f')
65 return (c - 'a' + 10);
66 if (c >= 'A' && c <= 'F')
67 return (c - 'A' + 10);
71 /* Convert a string representation of a MAC address ("xx:xx:xx:xx:xx:xx")
72 into binary format (6 bytes).
74 This function expects that each byte is represented with 2 characters
75 (e.g., 11:2:11:11:11:11 is invalid)
78 static char *eth_str2addr(char *ethstr, u8 * addr)
83 /* get rid of initial blanks */
84 while (*pos == ' ' || *pos == '\t')
87 for (i = 0; i < 6; i++) {
88 val = hex2int(*pos++);
91 val2 = hex2int(*pos++);
94 addr[i] = (val * 16 + val2) & 0xff;
96 if (i < 5 && *pos++ != ':')
102 /* this writes xx:xx:xx:xx:xx:xx into ethstr
103 (ethstr must have space for 18 chars) */
104 static int eth_addr2str(u8 * addr, char *ethstr)
109 for (i = 0; i < 6; i++) {
110 sprintf(pos, "%02x", addr[i] & 0xff);
119 * @brief Add an entry to the BT table
120 * @param priv A pointer to wlan_private structure
121 * @param req A pointer to ifreq structure
122 * @return 0 --success, otherwise fail
124 static int wlan_bt_add_ioctl(wlan_private * priv, struct ifreq *req)
126 struct iwreq *wrq = (struct iwreq *)req;
127 char ethaddrs_str[18];
129 u8 ethaddr[ETH_ALEN];
132 lbs_deb_enter(LBS_DEB_IOCTL);
134 if (copy_from_user(ethaddrs_str, wrq->u.data.pointer,
135 sizeof(ethaddrs_str)))
138 if ((pos = eth_str2addr(ethaddrs_str, ethaddr)) == NULL) {
139 lbs_pr_info("BT_ADD: Invalid MAC address\n");
143 lbs_deb_ioctl("BT: adding %s\n", ethaddrs_str);
144 ret = libertas_prepare_and_send_command(priv, cmd_bt_access,
145 cmd_act_bt_access_add,
146 cmd_option_waitforrsp, 0, ethaddr);
147 lbs_deb_leave_args(LBS_DEB_IOCTL, "ret %d", ret);
152 * @brief Delete an entry from the BT table
153 * @param priv A pointer to wlan_private structure
154 * @param req A pointer to ifreq structure
155 * @return 0 --success, otherwise fail
157 static int wlan_bt_del_ioctl(wlan_private * priv, struct ifreq *req)
159 struct iwreq *wrq = (struct iwreq *)req;
160 char ethaddrs_str[18];
161 u8 ethaddr[ETH_ALEN];
164 lbs_deb_enter(LBS_DEB_IOCTL);
166 if (copy_from_user(ethaddrs_str, wrq->u.data.pointer,
167 sizeof(ethaddrs_str)))
170 if ((pos = eth_str2addr(ethaddrs_str, ethaddr)) == NULL) {
171 lbs_pr_info("Invalid MAC address\n");
175 lbs_deb_ioctl("BT: deleting %s\n", ethaddrs_str);
177 return (libertas_prepare_and_send_command(priv,
179 cmd_act_bt_access_del,
180 cmd_option_waitforrsp, 0, ethaddr));
182 lbs_deb_leave(LBS_DEB_IOCTL);
187 * @brief Reset all entries from the BT table
188 * @param priv A pointer to wlan_private structure
189 * @return 0 --success, otherwise fail
191 static int wlan_bt_reset_ioctl(wlan_private * priv)
193 lbs_deb_enter(LBS_DEB_IOCTL);
195 lbs_pr_alert( "BT: resetting\n");
197 return (libertas_prepare_and_send_command(priv,
199 cmd_act_bt_access_reset,
200 cmd_option_waitforrsp, 0, NULL));
202 lbs_deb_leave(LBS_DEB_IOCTL);
207 * @brief List an entry from the BT table
208 * @param priv A pointer to wlan_private structure
209 * @param req A pointer to ifreq structure
210 * @return 0 --success, otherwise fail
212 static int wlan_bt_list_ioctl(wlan_private * priv, struct ifreq *req)
216 struct iwreq *wrq = (struct iwreq *)req;
217 /* used to pass id and store the bt entry returned by the FW */
220 char addr1addr2[2 * ETH_ALEN];
222 static char outstr[64];
226 lbs_deb_enter(LBS_DEB_IOCTL);
228 if (copy_from_user(outstr, wrq->u.data.pointer, sizeof(outstr))) {
229 lbs_deb_ioctl("Copy from user failed\n");
232 param.id = simple_strtoul(outstr, NULL, 10);
233 pos = sprintf(pbuf, "%d: ", param.id);
236 ret = libertas_prepare_and_send_command(priv, cmd_bt_access,
237 cmd_act_bt_access_list,
238 cmd_option_waitforrsp, 0,
242 addr1 = param.addr1addr2;
244 pos = sprintf(pbuf, "ignoring traffic from ");
246 pos = eth_addr2str(addr1, pbuf);
249 sprintf(pbuf, "(null)");
253 wrq->u.data.length = strlen(outstr);
254 if (copy_to_user(wrq->u.data.pointer, (char *)outstr,
255 wrq->u.data.length)) {
256 lbs_deb_ioctl("BT_LIST: Copy to user failed!\n");
260 lbs_deb_leave(LBS_DEB_IOCTL);
265 * @brief Find the next parameter in an input string
266 * @param ptr A pointer to the input parameter string
267 * @return A pointer to the next parameter, or 0 if no parameters left.
269 static char * next_param(char * ptr)
271 if (!ptr) return NULL;
272 while (*ptr == ' ' || *ptr == '\t') ++ptr;
273 return (*ptr == '\0') ? NULL : ptr;
277 * @brief Add an entry to the FWT table
278 * @param priv A pointer to wlan_private structure
279 * @param req A pointer to ifreq structure
280 * @return 0 --success, otherwise fail
282 static int wlan_fwt_add_ioctl(wlan_private * priv, struct ifreq *req)
284 struct iwreq *wrq = (struct iwreq *)req;
286 static struct cmd_ds_fwt_access fwt_access;
290 lbs_deb_enter(LBS_DEB_IOCTL);
292 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str)))
295 if ((ptr = eth_str2addr(in_str, fwt_access.da)) == NULL) {
296 lbs_pr_alert( "FWT_ADD: Invalid MAC address 1\n");
300 if ((ptr = eth_str2addr(ptr, fwt_access.ra)) == NULL) {
301 lbs_pr_alert( "FWT_ADD: Invalid MAC address 2\n");
305 if ((ptr = next_param(ptr)))
307 cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
309 fwt_access.metric = FWT_DEFAULT_METRIC;
311 if ((ptr = next_param(ptr)))
312 fwt_access.dir = (u8)simple_strtoul(ptr, &ptr, 10);
314 fwt_access.dir = FWT_DEFAULT_DIR;
316 if ((ptr = next_param(ptr)))
318 cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
320 fwt_access.ssn = FWT_DEFAULT_SSN;
322 if ((ptr = next_param(ptr)))
324 cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
326 fwt_access.dsn = FWT_DEFAULT_DSN;
328 if ((ptr = next_param(ptr)))
329 fwt_access.hopcount = simple_strtoul(ptr, &ptr, 10);
331 fwt_access.hopcount = FWT_DEFAULT_HOPCOUNT;
333 if ((ptr = next_param(ptr)))
334 fwt_access.ttl = simple_strtoul(ptr, &ptr, 10);
336 fwt_access.ttl = FWT_DEFAULT_TTL;
338 if ((ptr = next_param(ptr)))
339 fwt_access.expiration =
340 cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
342 fwt_access.expiration = FWT_DEFAULT_EXPIRATION;
344 if ((ptr = next_param(ptr)))
345 fwt_access.sleepmode = (u8)simple_strtoul(ptr, &ptr, 10);
347 fwt_access.sleepmode = FWT_DEFAULT_SLEEPMODE;
349 if ((ptr = next_param(ptr)))
351 cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
353 fwt_access.snr = FWT_DEFAULT_SNR;
357 char ethaddr1_str[18], ethaddr2_str[18];
358 eth_addr2str(fwt_access.da, ethaddr1_str);
359 eth_addr2str(fwt_access.ra, ethaddr2_str);
360 lbs_deb_ioctl("FWT_ADD: adding (da:%s,%i,ra:%s)\n", ethaddr1_str,
361 fwt_access.dir, ethaddr2_str);
362 lbs_deb_ioctl("FWT_ADD: ssn:%u dsn:%u met:%u hop:%u ttl:%u exp:%u slp:%u snr:%u\n",
363 fwt_access.ssn, fwt_access.dsn, fwt_access.metric,
364 fwt_access.hopcount, fwt_access.ttl, fwt_access.expiration,
365 fwt_access.sleepmode, fwt_access.snr);
369 ret = libertas_prepare_and_send_command(priv, cmd_fwt_access,
370 cmd_act_fwt_access_add,
371 cmd_option_waitforrsp, 0,
372 (void *)&fwt_access);
374 lbs_deb_leave_args(LBS_DEB_IOCTL, "ret %d", ret);
379 * @brief Delete an entry from the FWT table
380 * @param priv A pointer to wlan_private structure
381 * @param req A pointer to ifreq structure
382 * @return 0 --success, otherwise fail
384 static int wlan_fwt_del_ioctl(wlan_private * priv, struct ifreq *req)
386 struct iwreq *wrq = (struct iwreq *)req;
388 static struct cmd_ds_fwt_access fwt_access;
392 lbs_deb_enter(LBS_DEB_IOCTL);
394 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str)))
397 if ((ptr = eth_str2addr(in_str, fwt_access.da)) == NULL) {
398 lbs_pr_alert( "FWT_DEL: Invalid MAC address 1\n");
402 if ((ptr = eth_str2addr(ptr, fwt_access.ra)) == NULL) {
403 lbs_pr_alert( "FWT_DEL: Invalid MAC address 2\n");
407 if ((ptr = next_param(ptr)))
408 fwt_access.dir = (u8)simple_strtoul(ptr, &ptr, 10);
410 fwt_access.dir = FWT_DEFAULT_DIR;
414 char ethaddr1_str[18], ethaddr2_str[18];
415 lbs_deb_ioctl("FWT_DEL: line is %s\n", in_str);
416 eth_addr2str(fwt_access.da, ethaddr1_str);
417 eth_addr2str(fwt_access.ra, ethaddr2_str);
418 lbs_deb_ioctl("FWT_DEL: removing (da:%s,ra:%s,dir:%d)\n", ethaddr1_str,
419 ethaddr2_str, fwt_access.dir);
423 ret = libertas_prepare_and_send_command(priv,
425 cmd_act_fwt_access_del,
426 cmd_option_waitforrsp, 0,
427 (void *)&fwt_access);
428 lbs_deb_leave_args(LBS_DEB_IOCTL, "ret %d", ret);
434 * @brief Print route parameters
435 * @param fwt_access struct cmd_ds_fwt_access with route info
436 * @param buf destination buffer for route info
438 static void print_route(struct cmd_ds_fwt_access fwt_access, char *buf)
440 buf += sprintf(buf, " ");
441 buf += eth_addr2str(fwt_access.da, buf);
442 buf += sprintf(buf, " ");
443 buf += eth_addr2str(fwt_access.ra, buf);
444 buf += sprintf(buf, " %u", le32_to_cpu(fwt_access.metric));
445 buf += sprintf(buf, " %u", fwt_access.dir);
446 buf += sprintf(buf, " %u", le32_to_cpu(fwt_access.ssn));
447 buf += sprintf(buf, " %u", le32_to_cpu(fwt_access.dsn));
448 buf += sprintf(buf, " %u", fwt_access.hopcount);
449 buf += sprintf(buf, " %u", fwt_access.ttl);
450 buf += sprintf(buf, " %u", le32_to_cpu(fwt_access.expiration));
451 buf += sprintf(buf, " %u", fwt_access.sleepmode);
452 buf += sprintf(buf, " %u", le32_to_cpu(fwt_access.snr));
456 * @brief Lookup an entry in the FWT table
457 * @param priv A pointer to wlan_private structure
458 * @param req A pointer to ifreq structure
459 * @return 0 --success, otherwise fail
461 static int wlan_fwt_lookup_ioctl(wlan_private * priv, struct ifreq *req)
463 struct iwreq *wrq = (struct iwreq *)req;
466 static struct cmd_ds_fwt_access fwt_access;
467 static char out_str[128];
470 lbs_deb_enter(LBS_DEB_IOCTL);
472 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str)))
475 if ((ptr = eth_str2addr(in_str, fwt_access.da)) == NULL) {
476 lbs_pr_alert( "FWT_LOOKUP: Invalid MAC address\n");
482 char ethaddr1_str[18];
483 lbs_deb_ioctl("FWT_LOOKUP: line is %s\n", in_str);
484 eth_addr2str(fwt_access.da, ethaddr1_str);
485 lbs_deb_ioctl("FWT_LOOKUP: looking for (da:%s)\n", ethaddr1_str);
489 ret = libertas_prepare_and_send_command(priv,
491 cmd_act_fwt_access_lookup,
492 cmd_option_waitforrsp, 0,
493 (void *)&fwt_access);
496 print_route(fwt_access, out_str);
498 sprintf(out_str, "(null)");
500 wrq->u.data.length = strlen(out_str);
501 if (copy_to_user(wrq->u.data.pointer, (char *)out_str,
502 wrq->u.data.length)) {
503 lbs_deb_ioctl("FWT_LOOKUP: Copy to user failed!\n");
507 lbs_deb_leave(LBS_DEB_IOCTL);
512 * @brief Reset all entries from the FWT table
513 * @param priv A pointer to wlan_private structure
514 * @return 0 --success, otherwise fail
516 static int wlan_fwt_reset_ioctl(wlan_private * priv)
518 lbs_deb_ioctl("FWT: resetting\n");
520 return (libertas_prepare_and_send_command(priv,
522 cmd_act_fwt_access_reset,
523 cmd_option_waitforrsp, 0, NULL));
527 * @brief List an entry from the FWT table
528 * @param priv A pointer to wlan_private structure
529 * @param req A pointer to ifreq structure
530 * @return 0 --success, otherwise fail
532 static int wlan_fwt_list_ioctl(wlan_private * priv, struct ifreq *req)
534 struct iwreq *wrq = (struct iwreq *)req;
536 static struct cmd_ds_fwt_access fwt_access;
538 static char out_str[128];
539 char *pbuf = out_str;
542 lbs_deb_enter(LBS_DEB_IOCTL);
544 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str)))
547 fwt_access.id = cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
551 lbs_deb_ioctl("FWT_LIST: line is %s\n", in_str);
552 lbs_deb_ioctl("FWT_LIST: listing id:%i\n", le32_to_cpu(fwt_access.id));
556 ret = libertas_prepare_and_send_command(priv, cmd_fwt_access,
557 cmd_act_fwt_access_list,
558 cmd_option_waitforrsp, 0, (void *)&fwt_access);
561 print_route(fwt_access, pbuf);
563 pbuf += sprintf(pbuf, " (null)");
565 wrq->u.data.length = strlen(out_str);
566 if (copy_to_user(wrq->u.data.pointer, (char *)out_str,
567 wrq->u.data.length)) {
568 lbs_deb_ioctl("FWT_LIST: Copy to user failed!\n");
572 lbs_deb_leave(LBS_DEB_IOCTL);
577 * @brief List an entry from the FRT table
578 * @param priv A pointer to wlan_private structure
579 * @param req A pointer to ifreq structure
580 * @return 0 --success, otherwise fail
582 static int wlan_fwt_list_route_ioctl(wlan_private * priv, struct ifreq *req)
584 struct iwreq *wrq = (struct iwreq *)req;
586 static struct cmd_ds_fwt_access fwt_access;
588 static char out_str[128];
589 char *pbuf = out_str;
592 lbs_deb_enter(LBS_DEB_IOCTL);
594 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str)))
597 fwt_access.id = cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
601 lbs_deb_ioctl("FWT_LIST_ROUTE: line is %s\n", in_str);
602 lbs_deb_ioctl("FWT_LIST_ROUTE: listing id:%i\n", le32_to_cpu(fwt_access.id));
606 ret = libertas_prepare_and_send_command(priv, cmd_fwt_access,
607 cmd_act_fwt_access_list_route,
608 cmd_option_waitforrsp, 0, (void *)&fwt_access);
611 pbuf += sprintf(pbuf, " ");
612 pbuf += eth_addr2str(fwt_access.da, pbuf);
613 pbuf += sprintf(pbuf, " %u", le32_to_cpu(fwt_access.metric));
614 pbuf += sprintf(pbuf, " %u", fwt_access.dir);
615 /* note that the firmware returns the nid in the id field */
616 pbuf += sprintf(pbuf, " %u", le32_to_cpu(fwt_access.id));
617 pbuf += sprintf(pbuf, " %u", le32_to_cpu(fwt_access.ssn));
618 pbuf += sprintf(pbuf, " %u", le32_to_cpu(fwt_access.dsn));
619 pbuf += sprintf(pbuf, " hop %u", fwt_access.hopcount);
620 pbuf += sprintf(pbuf, " ttl %u", fwt_access.ttl);
621 pbuf += sprintf(pbuf, " %u", le32_to_cpu(fwt_access.expiration));
623 pbuf += sprintf(pbuf, " (null)");
625 wrq->u.data.length = strlen(out_str);
626 if (copy_to_user(wrq->u.data.pointer, (char *)out_str,
627 wrq->u.data.length)) {
628 lbs_deb_ioctl("FWT_LIST_ROUTE: Copy to user failed!\n");
632 lbs_deb_leave(LBS_DEB_IOCTL);
637 * @brief List an entry from the FNT table
638 * @param priv A pointer to wlan_private structure
639 * @param req A pointer to ifreq structure
640 * @return 0 --success, otherwise fail
642 static int wlan_fwt_list_neighbor_ioctl(wlan_private * priv, struct ifreq *req)
644 struct iwreq *wrq = (struct iwreq *)req;
646 static struct cmd_ds_fwt_access fwt_access;
648 static char out_str[128];
649 char *pbuf = out_str;
652 lbs_deb_enter(LBS_DEB_IOCTL);
654 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str)))
657 memset(&fwt_access, 0, sizeof(fwt_access));
658 fwt_access.id = cpu_to_le32(simple_strtoul(ptr, &ptr, 10));
662 lbs_deb_ioctl("FWT_LIST_NEIGHBOR: line is %s\n", in_str);
663 lbs_deb_ioctl("FWT_LIST_NEIGHBOR: listing id:%i\n", le32_to_cpu(fwt_access.id));
667 ret = libertas_prepare_and_send_command(priv, cmd_fwt_access,
668 cmd_act_fwt_access_list_neighbor,
669 cmd_option_waitforrsp, 0,
670 (void *)&fwt_access);
673 pbuf += sprintf(pbuf, " ra ");
674 pbuf += eth_addr2str(fwt_access.ra, pbuf);
675 pbuf += sprintf(pbuf, " slp %u", fwt_access.sleepmode);
676 pbuf += sprintf(pbuf, " snr %u", le32_to_cpu(fwt_access.snr));
677 pbuf += sprintf(pbuf, " ref %u", le32_to_cpu(fwt_access.references));
679 pbuf += sprintf(pbuf, " (null)");
681 wrq->u.data.length = strlen(out_str);
682 if (copy_to_user(wrq->u.data.pointer, (char *)out_str,
683 wrq->u.data.length)) {
684 lbs_deb_ioctl("FWT_LIST_NEIGHBOR: Copy to user failed!\n");
688 lbs_deb_leave(LBS_DEB_IOCTL);
693 * @brief Cleans up the route (FRT) and neighbor (FNT) tables
694 * (Garbage Collection)
695 * @param priv A pointer to wlan_private structure
696 * @param req A pointer to ifreq structure
697 * @return 0 --success, otherwise fail
699 static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req)
701 struct iwreq *wrq = (struct iwreq *)req;
702 static struct cmd_ds_fwt_access fwt_access;
705 lbs_deb_enter(LBS_DEB_IOCTL);
707 lbs_deb_ioctl("FWT: cleaning up\n");
709 memset(&fwt_access, 0, sizeof(fwt_access));
711 ret = libertas_prepare_and_send_command(priv, cmd_fwt_access,
712 cmd_act_fwt_access_cleanup,
713 cmd_option_waitforrsp, 0,
714 (void *)&fwt_access);
717 wrq->u.param.value = le32_to_cpu(fwt_access.references);
721 lbs_deb_leave(LBS_DEB_IOCTL);
726 * @brief Gets firmware internal time (debug purposes)
727 * @param priv A pointer to wlan_private structure
728 * @param req A pointer to ifreq structure
729 * @return 0 --success, otherwise fail
731 static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req)
733 struct iwreq *wrq = (struct iwreq *)req;
734 static struct cmd_ds_fwt_access fwt_access;
737 lbs_deb_enter(LBS_DEB_IOCTL);
739 lbs_deb_ioctl("FWT: getting time\n");
741 memset(&fwt_access, 0, sizeof(fwt_access));
743 ret = libertas_prepare_and_send_command(priv, cmd_fwt_access,
744 cmd_act_fwt_access_time,
745 cmd_option_waitforrsp, 0,
746 (void *)&fwt_access);
749 wrq->u.param.value = le32_to_cpu(fwt_access.references);
753 lbs_deb_leave(LBS_DEB_IOCTL);
758 * @brief Gets mesh ttl from firmware
759 * @param priv A pointer to wlan_private structure
760 * @param req A pointer to ifreq structure
761 * @return 0 --success, otherwise fail
763 static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req)
765 struct iwreq *wrq = (struct iwreq *)req;
766 struct cmd_ds_mesh_access mesh_access;
769 lbs_deb_enter(LBS_DEB_IOCTL);
771 memset(&mesh_access, 0, sizeof(mesh_access));
773 ret = libertas_prepare_and_send_command(priv, cmd_mesh_access,
774 cmd_act_mesh_get_ttl,
775 cmd_option_waitforrsp, 0,
776 (void *)&mesh_access);
779 wrq->u.param.value = le32_to_cpu(mesh_access.data[0]);
783 lbs_deb_leave(LBS_DEB_IOCTL);
788 * @brief Gets mesh ttl from firmware
789 * @param priv A pointer to wlan_private structure
790 * @param ttl New ttl value
791 * @return 0 --success, otherwise fail
793 static int wlan_mesh_set_ttl_ioctl(wlan_private * priv, int ttl)
795 struct cmd_ds_mesh_access mesh_access;
798 lbs_deb_enter(LBS_DEB_IOCTL);
800 if( (ttl > 0xff) || (ttl < 0) )
803 memset(&mesh_access, 0, sizeof(mesh_access));
804 mesh_access.data[0] = ttl;
806 ret = libertas_prepare_and_send_command(priv, cmd_mesh_access,
807 cmd_act_mesh_set_ttl,
808 cmd_option_waitforrsp, 0,
809 (void *)&mesh_access);
814 lbs_deb_leave(LBS_DEB_IOCTL);
819 * @brief ioctl function - entry point
821 * @param dev A pointer to net_device structure
822 * @param req A pointer to ifreq structure
824 * @return 0--success, otherwise fail
826 int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
832 wlan_private *priv = dev->priv;
833 wlan_adapter *adapter = priv->adapter;
834 struct iwreq *wrq = (struct iwreq *)req;
836 lbs_deb_enter(LBS_DEB_IOCTL);
838 lbs_deb_ioctl("libertas_do_ioctl: ioctl cmd = 0x%x\n", cmd);
840 case WLAN_SETNONE_GETNONE: /* set WPA mode on/off ioctl #20 */
841 switch (wrq->u.data.flags) {
842 case WLAN_SUBCMD_BT_RESET: /* bt_reset */
843 wlan_bt_reset_ioctl(priv);
845 case WLAN_SUBCMD_FWT_RESET: /* fwt_reset */
846 wlan_fwt_reset_ioctl(priv);
848 } /* End of switch */
851 case WLAN_SETONEINT_GETNONE:
852 /* The first 4 bytes of req->ifr_data is sub-ioctl number
853 * after 4 bytes sits the payload.
855 subcmd = wrq->u.data.flags;
857 subcmd = (int)wrq->u.param.value;
861 idata = SUBCMD_DATA(wrq);
862 ret = wlan_set_region(priv, (u16) idata);
864 case WLAN_SUBCMD_MESH_SET_TTL:
865 idata = SUBCMD_DATA(wrq);
866 ret = wlan_mesh_set_ttl_ioctl(priv, idata);
876 case WLAN_SET128CHAR_GET128CHAR:
877 switch ((int)wrq->u.data.flags) {
878 case WLAN_SUBCMD_BT_ADD:
879 ret = wlan_bt_add_ioctl(priv, req);
881 case WLAN_SUBCMD_BT_DEL:
882 ret = wlan_bt_del_ioctl(priv, req);
884 case WLAN_SUBCMD_BT_LIST:
885 ret = wlan_bt_list_ioctl(priv, req);
887 case WLAN_SUBCMD_FWT_ADD:
888 ret = wlan_fwt_add_ioctl(priv, req);
890 case WLAN_SUBCMD_FWT_DEL:
891 ret = wlan_fwt_del_ioctl(priv, req);
893 case WLAN_SUBCMD_FWT_LOOKUP:
894 ret = wlan_fwt_lookup_ioctl(priv, req);
896 case WLAN_SUBCMD_FWT_LIST_NEIGHBOR:
897 ret = wlan_fwt_list_neighbor_ioctl(priv, req);
899 case WLAN_SUBCMD_FWT_LIST:
900 ret = wlan_fwt_list_ioctl(priv, req);
902 case WLAN_SUBCMD_FWT_LIST_ROUTE:
903 ret = wlan_fwt_list_route_ioctl(priv, req);
908 case WLAN_SETNONE_GETONEINT:
909 switch (wrq->u.param.value) {
911 pdata = (int *)wrq->u.name;
912 *pdata = (int)adapter->regioncode;
914 case WLAN_SUBCMD_FWT_CLEANUP: /* fwt_cleanup */
915 ret = wlan_fwt_cleanup_ioctl(priv, req);
918 case WLAN_SUBCMD_FWT_TIME: /* fwt_time */
919 ret = wlan_fwt_time_ioctl(priv, req);
922 case WLAN_SUBCMD_MESH_GET_TTL:
923 ret = wlan_mesh_get_ttl_ioctl(priv, req);
933 case WLAN_SET_GET_SIXTEEN_INT:
934 switch ((int)wrq->u.data.flags) {
935 case WLAN_LED_GPIO_CTRL:
940 struct cmd_ds_802_11_led_ctrl ctrl;
941 struct mrvlietypes_ledgpio *gpio =
942 (struct mrvlietypes_ledgpio *) ctrl.data;
944 memset(&ctrl, 0, sizeof(ctrl));
945 if (wrq->u.data.length > MAX_LEDS * 2)
947 if ((wrq->u.data.length % 2) != 0)
949 if (wrq->u.data.length == 0) {
955 (data, wrq->u.data.pointer,
957 wrq->u.data.length)) {
959 "Copy from user failed\n");
966 ctrl.numled = cpu_to_le16(0);
968 cpu_to_le16(TLV_TYPE_LED_GPIO);
969 gpio->header.len = wrq->u.data.length;
970 for (i = 0; i < wrq->u.data.length;
972 gpio->ledpin[i / 2].led =
974 gpio->ledpin[i / 2].pin =
979 libertas_prepare_and_send_command(priv,
980 cmd_802_11_led_gpio_ctrl,
982 cmd_option_waitforrsp,
984 for (i = 0; i < gpio->header.len; i += 2) {
985 data[i] = gpio->ledpin[i / 2].led;
986 data[i + 1] = gpio->ledpin[i / 2].pin;
988 if (copy_to_user(wrq->u.data.pointer, data,
991 lbs_deb_ioctl("Copy to user failed\n");
995 wrq->u.data.length = gpio->header.len;
1006 lbs_deb_leave_args(LBS_DEB_IOCTL, "ret %d", ret);