diff options
author | Holger Schurig <holgerschurig@gmail.com> | 2009-11-25 07:11:16 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-11-28 15:04:59 -0500 |
commit | ece1e3c61e59ba184150e5aff57bbc6355613e3e (patch) | |
tree | fb6b71185eea092333d10e5c3729ea7bc8f37a2f /drivers | |
parent | c7fe64cf4a08561a9e8f57e6018a504881236e34 (diff) |
libertas: move mesh command handling into mesh.c
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/libertas/cmd.c | 168 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/mesh.c | 175 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/mesh.h | 11 |
3 files changed, 186 insertions, 168 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index 1065ce29cd08..b9b371bfa30f 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c | |||
@@ -3,7 +3,6 @@ | |||
3 | * It prepares command and sends it to firmware when it is ready. | 3 | * It prepares command and sends it to firmware when it is ready. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <net/lib80211.h> | ||
7 | #include <linux/kfifo.h> | 6 | #include <linux/kfifo.h> |
8 | #include <linux/sched.h> | 7 | #include <linux/sched.h> |
9 | 8 | ||
@@ -697,173 +696,6 @@ static int lbs_cmd_reg_access(struct cmd_ds_command *cmdptr, | |||
697 | return 0; | 696 | return 0; |
698 | } | 697 | } |
699 | 698 | ||
700 | static int lbs_cmd_bt_access(struct cmd_ds_command *cmd, | ||
701 | u16 cmd_action, void *pdata_buf) | ||
702 | { | ||
703 | struct cmd_ds_bt_access *bt_access = &cmd->params.bt; | ||
704 | lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); | ||
705 | |||
706 | cmd->command = cpu_to_le16(CMD_BT_ACCESS); | ||
707 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_bt_access) + | ||
708 | sizeof(struct cmd_header)); | ||
709 | cmd->result = 0; | ||
710 | bt_access->action = cpu_to_le16(cmd_action); | ||
711 | |||
712 | switch (cmd_action) { | ||
713 | case CMD_ACT_BT_ACCESS_ADD: | ||
714 | memcpy(bt_access->addr1, pdata_buf, 2 * ETH_ALEN); | ||
715 | lbs_deb_hex(LBS_DEB_MESH, "BT_ADD: blinded MAC addr", bt_access->addr1, 6); | ||
716 | break; | ||
717 | case CMD_ACT_BT_ACCESS_DEL: | ||
718 | memcpy(bt_access->addr1, pdata_buf, 1 * ETH_ALEN); | ||
719 | lbs_deb_hex(LBS_DEB_MESH, "BT_DEL: blinded MAC addr", bt_access->addr1, 6); | ||
720 | break; | ||
721 | case CMD_ACT_BT_ACCESS_LIST: | ||
722 | bt_access->id = cpu_to_le32(*(u32 *) pdata_buf); | ||
723 | break; | ||
724 | case CMD_ACT_BT_ACCESS_RESET: | ||
725 | break; | ||
726 | case CMD_ACT_BT_ACCESS_SET_INVERT: | ||
727 | bt_access->id = cpu_to_le32(*(u32 *) pdata_buf); | ||
728 | break; | ||
729 | case CMD_ACT_BT_ACCESS_GET_INVERT: | ||
730 | break; | ||
731 | default: | ||
732 | break; | ||
733 | } | ||
734 | lbs_deb_leave(LBS_DEB_CMD); | ||
735 | return 0; | ||
736 | } | ||
737 | |||
738 | static int lbs_cmd_fwt_access(struct cmd_ds_command *cmd, | ||
739 | u16 cmd_action, void *pdata_buf) | ||
740 | { | ||
741 | struct cmd_ds_fwt_access *fwt_access = &cmd->params.fwt; | ||
742 | lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); | ||
743 | |||
744 | cmd->command = cpu_to_le16(CMD_FWT_ACCESS); | ||
745 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_fwt_access) + | ||
746 | sizeof(struct cmd_header)); | ||
747 | cmd->result = 0; | ||
748 | |||
749 | if (pdata_buf) | ||
750 | memcpy(fwt_access, pdata_buf, sizeof(*fwt_access)); | ||
751 | else | ||
752 | memset(fwt_access, 0, sizeof(*fwt_access)); | ||
753 | |||
754 | fwt_access->action = cpu_to_le16(cmd_action); | ||
755 | |||
756 | lbs_deb_leave(LBS_DEB_CMD); | ||
757 | return 0; | ||
758 | } | ||
759 | |||
760 | int lbs_mesh_access(struct lbs_private *priv, uint16_t cmd_action, | ||
761 | struct cmd_ds_mesh_access *cmd) | ||
762 | { | ||
763 | int ret; | ||
764 | |||
765 | lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); | ||
766 | |||
767 | cmd->hdr.command = cpu_to_le16(CMD_MESH_ACCESS); | ||
768 | cmd->hdr.size = cpu_to_le16(sizeof(*cmd)); | ||
769 | cmd->hdr.result = 0; | ||
770 | |||
771 | cmd->action = cpu_to_le16(cmd_action); | ||
772 | |||
773 | ret = lbs_cmd_with_response(priv, CMD_MESH_ACCESS, cmd); | ||
774 | |||
775 | lbs_deb_leave(LBS_DEB_CMD); | ||
776 | return ret; | ||
777 | } | ||
778 | |||
779 | static int __lbs_mesh_config_send(struct lbs_private *priv, | ||
780 | struct cmd_ds_mesh_config *cmd, | ||
781 | uint16_t action, uint16_t type) | ||
782 | { | ||
783 | int ret; | ||
784 | u16 command = CMD_MESH_CONFIG_OLD; | ||
785 | |||
786 | lbs_deb_enter(LBS_DEB_CMD); | ||
787 | |||
788 | /* | ||
789 | * Command id is 0xac for v10 FW along with mesh interface | ||
790 | * id in bits 14-13-12. | ||
791 | */ | ||
792 | if (priv->mesh_fw_ver == MESH_FW_NEW) | ||
793 | command = CMD_MESH_CONFIG | | ||
794 | (MESH_IFACE_ID << MESH_IFACE_BIT_OFFSET); | ||
795 | |||
796 | cmd->hdr.command = cpu_to_le16(command); | ||
797 | cmd->hdr.size = cpu_to_le16(sizeof(struct cmd_ds_mesh_config)); | ||
798 | cmd->hdr.result = 0; | ||
799 | |||
800 | cmd->type = cpu_to_le16(type); | ||
801 | cmd->action = cpu_to_le16(action); | ||
802 | |||
803 | ret = lbs_cmd_with_response(priv, command, cmd); | ||
804 | |||
805 | lbs_deb_leave(LBS_DEB_CMD); | ||
806 | return ret; | ||
807 | } | ||
808 | |||
809 | int lbs_mesh_config_send(struct lbs_private *priv, | ||
810 | struct cmd_ds_mesh_config *cmd, | ||
811 | uint16_t action, uint16_t type) | ||
812 | { | ||
813 | int ret; | ||
814 | |||
815 | if (!(priv->fwcapinfo & FW_CAPINFO_PERSISTENT_CONFIG)) | ||
816 | return -EOPNOTSUPP; | ||
817 | |||
818 | ret = __lbs_mesh_config_send(priv, cmd, action, type); | ||
819 | return ret; | ||
820 | } | ||
821 | |||
822 | /* This function is the CMD_MESH_CONFIG legacy function. It only handles the | ||
823 | * START and STOP actions. The extended actions supported by CMD_MESH_CONFIG | ||
824 | * are all handled by preparing a struct cmd_ds_mesh_config and passing it to | ||
825 | * lbs_mesh_config_send. | ||
826 | */ | ||
827 | int lbs_mesh_config(struct lbs_private *priv, uint16_t action, uint16_t chan) | ||
828 | { | ||
829 | struct cmd_ds_mesh_config cmd; | ||
830 | struct mrvl_meshie *ie; | ||
831 | DECLARE_SSID_BUF(ssid); | ||
832 | |||
833 | memset(&cmd, 0, sizeof(cmd)); | ||
834 | cmd.channel = cpu_to_le16(chan); | ||
835 | ie = (struct mrvl_meshie *)cmd.data; | ||
836 | |||
837 | switch (action) { | ||
838 | case CMD_ACT_MESH_CONFIG_START: | ||
839 | ie->id = WLAN_EID_GENERIC; | ||
840 | ie->val.oui[0] = 0x00; | ||
841 | ie->val.oui[1] = 0x50; | ||
842 | ie->val.oui[2] = 0x43; | ||
843 | ie->val.type = MARVELL_MESH_IE_TYPE; | ||
844 | ie->val.subtype = MARVELL_MESH_IE_SUBTYPE; | ||
845 | ie->val.version = MARVELL_MESH_IE_VERSION; | ||
846 | ie->val.active_protocol_id = MARVELL_MESH_PROTO_ID_HWMP; | ||
847 | ie->val.active_metric_id = MARVELL_MESH_METRIC_ID; | ||
848 | ie->val.mesh_capability = MARVELL_MESH_CAPABILITY; | ||
849 | ie->val.mesh_id_len = priv->mesh_ssid_len; | ||
850 | memcpy(ie->val.mesh_id, priv->mesh_ssid, priv->mesh_ssid_len); | ||
851 | ie->len = sizeof(struct mrvl_meshie_val) - | ||
852 | IEEE80211_MAX_SSID_LEN + priv->mesh_ssid_len; | ||
853 | cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie_val)); | ||
854 | break; | ||
855 | case CMD_ACT_MESH_CONFIG_STOP: | ||
856 | break; | ||
857 | default: | ||
858 | return -1; | ||
859 | } | ||
860 | lbs_deb_cmd("mesh config action %d type %x channel %d SSID %s\n", | ||
861 | action, priv->mesh_tlv, chan, | ||
862 | print_ssid(ssid, priv->mesh_ssid, priv->mesh_ssid_len)); | ||
863 | |||
864 | return __lbs_mesh_config_send(priv, &cmd, action, priv->mesh_tlv); | ||
865 | } | ||
866 | |||
867 | static void lbs_queue_cmd(struct lbs_private *priv, | 699 | static void lbs_queue_cmd(struct lbs_private *priv, |
868 | struct cmd_ctrl_node *cmdnode) | 700 | struct cmd_ctrl_node *cmdnode) |
869 | { | 701 | { |
diff --git a/drivers/net/wireless/libertas/mesh.c b/drivers/net/wireless/libertas/mesh.c index 3e12060a6470..2f91c9b808af 100644 --- a/drivers/net/wireless/libertas/mesh.c +++ b/drivers/net/wireless/libertas/mesh.c | |||
@@ -441,6 +441,181 @@ void lbs_mesh_set_txpd(struct lbs_private *priv, | |||
441 | 441 | ||
442 | 442 | ||
443 | /*************************************************************************** | 443 | /*************************************************************************** |
444 | * Mesh command handling | ||
445 | */ | ||
446 | |||
447 | int lbs_cmd_bt_access(struct cmd_ds_command *cmd, | ||
448 | u16 cmd_action, void *pdata_buf) | ||
449 | { | ||
450 | struct cmd_ds_bt_access *bt_access = &cmd->params.bt; | ||
451 | lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); | ||
452 | |||
453 | cmd->command = cpu_to_le16(CMD_BT_ACCESS); | ||
454 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_bt_access) + | ||
455 | sizeof(struct cmd_header)); | ||
456 | cmd->result = 0; | ||
457 | bt_access->action = cpu_to_le16(cmd_action); | ||
458 | |||
459 | switch (cmd_action) { | ||
460 | case CMD_ACT_BT_ACCESS_ADD: | ||
461 | memcpy(bt_access->addr1, pdata_buf, 2 * ETH_ALEN); | ||
462 | lbs_deb_hex(LBS_DEB_MESH, "BT_ADD: blinded MAC addr", | ||
463 | bt_access->addr1, 6); | ||
464 | break; | ||
465 | case CMD_ACT_BT_ACCESS_DEL: | ||
466 | memcpy(bt_access->addr1, pdata_buf, 1 * ETH_ALEN); | ||
467 | lbs_deb_hex(LBS_DEB_MESH, "BT_DEL: blinded MAC addr", | ||
468 | bt_access->addr1, 6); | ||
469 | break; | ||
470 | case CMD_ACT_BT_ACCESS_LIST: | ||
471 | bt_access->id = cpu_to_le32(*(u32 *) pdata_buf); | ||
472 | break; | ||
473 | case CMD_ACT_BT_ACCESS_RESET: | ||
474 | break; | ||
475 | case CMD_ACT_BT_ACCESS_SET_INVERT: | ||
476 | bt_access->id = cpu_to_le32(*(u32 *) pdata_buf); | ||
477 | break; | ||
478 | case CMD_ACT_BT_ACCESS_GET_INVERT: | ||
479 | break; | ||
480 | default: | ||
481 | break; | ||
482 | } | ||
483 | lbs_deb_leave(LBS_DEB_CMD); | ||
484 | return 0; | ||
485 | } | ||
486 | |||
487 | int lbs_cmd_fwt_access(struct cmd_ds_command *cmd, | ||
488 | u16 cmd_action, void *pdata_buf) | ||
489 | { | ||
490 | struct cmd_ds_fwt_access *fwt_access = &cmd->params.fwt; | ||
491 | lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); | ||
492 | |||
493 | cmd->command = cpu_to_le16(CMD_FWT_ACCESS); | ||
494 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_fwt_access) + | ||
495 | sizeof(struct cmd_header)); | ||
496 | cmd->result = 0; | ||
497 | |||
498 | if (pdata_buf) | ||
499 | memcpy(fwt_access, pdata_buf, sizeof(*fwt_access)); | ||
500 | else | ||
501 | memset(fwt_access, 0, sizeof(*fwt_access)); | ||
502 | |||
503 | fwt_access->action = cpu_to_le16(cmd_action); | ||
504 | |||
505 | lbs_deb_leave(LBS_DEB_CMD); | ||
506 | return 0; | ||
507 | } | ||
508 | |||
509 | int lbs_mesh_access(struct lbs_private *priv, uint16_t cmd_action, | ||
510 | struct cmd_ds_mesh_access *cmd) | ||
511 | { | ||
512 | int ret; | ||
513 | |||
514 | lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); | ||
515 | |||
516 | cmd->hdr.command = cpu_to_le16(CMD_MESH_ACCESS); | ||
517 | cmd->hdr.size = cpu_to_le16(sizeof(*cmd)); | ||
518 | cmd->hdr.result = 0; | ||
519 | |||
520 | cmd->action = cpu_to_le16(cmd_action); | ||
521 | |||
522 | ret = lbs_cmd_with_response(priv, CMD_MESH_ACCESS, cmd); | ||
523 | |||
524 | lbs_deb_leave(LBS_DEB_CMD); | ||
525 | return ret; | ||
526 | } | ||
527 | |||
528 | static int __lbs_mesh_config_send(struct lbs_private *priv, | ||
529 | struct cmd_ds_mesh_config *cmd, | ||
530 | uint16_t action, uint16_t type) | ||
531 | { | ||
532 | int ret; | ||
533 | u16 command = CMD_MESH_CONFIG_OLD; | ||
534 | |||
535 | lbs_deb_enter(LBS_DEB_CMD); | ||
536 | |||
537 | /* | ||
538 | * Command id is 0xac for v10 FW along with mesh interface | ||
539 | * id in bits 14-13-12. | ||
540 | */ | ||
541 | if (priv->mesh_fw_ver == MESH_FW_NEW) | ||
542 | command = CMD_MESH_CONFIG | | ||
543 | (MESH_IFACE_ID << MESH_IFACE_BIT_OFFSET); | ||
544 | |||
545 | cmd->hdr.command = cpu_to_le16(command); | ||
546 | cmd->hdr.size = cpu_to_le16(sizeof(struct cmd_ds_mesh_config)); | ||
547 | cmd->hdr.result = 0; | ||
548 | |||
549 | cmd->type = cpu_to_le16(type); | ||
550 | cmd->action = cpu_to_le16(action); | ||
551 | |||
552 | ret = lbs_cmd_with_response(priv, command, cmd); | ||
553 | |||
554 | lbs_deb_leave(LBS_DEB_CMD); | ||
555 | return ret; | ||
556 | } | ||
557 | |||
558 | int lbs_mesh_config_send(struct lbs_private *priv, | ||
559 | struct cmd_ds_mesh_config *cmd, | ||
560 | uint16_t action, uint16_t type) | ||
561 | { | ||
562 | int ret; | ||
563 | |||
564 | if (!(priv->fwcapinfo & FW_CAPINFO_PERSISTENT_CONFIG)) | ||
565 | return -EOPNOTSUPP; | ||
566 | |||
567 | ret = __lbs_mesh_config_send(priv, cmd, action, type); | ||
568 | return ret; | ||
569 | } | ||
570 | |||
571 | /* This function is the CMD_MESH_CONFIG legacy function. It only handles the | ||
572 | * START and STOP actions. The extended actions supported by CMD_MESH_CONFIG | ||
573 | * are all handled by preparing a struct cmd_ds_mesh_config and passing it to | ||
574 | * lbs_mesh_config_send. | ||
575 | */ | ||
576 | int lbs_mesh_config(struct lbs_private *priv, uint16_t action, uint16_t chan) | ||
577 | { | ||
578 | struct cmd_ds_mesh_config cmd; | ||
579 | struct mrvl_meshie *ie; | ||
580 | DECLARE_SSID_BUF(ssid); | ||
581 | |||
582 | memset(&cmd, 0, sizeof(cmd)); | ||
583 | cmd.channel = cpu_to_le16(chan); | ||
584 | ie = (struct mrvl_meshie *)cmd.data; | ||
585 | |||
586 | switch (action) { | ||
587 | case CMD_ACT_MESH_CONFIG_START: | ||
588 | ie->id = WLAN_EID_GENERIC; | ||
589 | ie->val.oui[0] = 0x00; | ||
590 | ie->val.oui[1] = 0x50; | ||
591 | ie->val.oui[2] = 0x43; | ||
592 | ie->val.type = MARVELL_MESH_IE_TYPE; | ||
593 | ie->val.subtype = MARVELL_MESH_IE_SUBTYPE; | ||
594 | ie->val.version = MARVELL_MESH_IE_VERSION; | ||
595 | ie->val.active_protocol_id = MARVELL_MESH_PROTO_ID_HWMP; | ||
596 | ie->val.active_metric_id = MARVELL_MESH_METRIC_ID; | ||
597 | ie->val.mesh_capability = MARVELL_MESH_CAPABILITY; | ||
598 | ie->val.mesh_id_len = priv->mesh_ssid_len; | ||
599 | memcpy(ie->val.mesh_id, priv->mesh_ssid, priv->mesh_ssid_len); | ||
600 | ie->len = sizeof(struct mrvl_meshie_val) - | ||
601 | IEEE80211_MAX_SSID_LEN + priv->mesh_ssid_len; | ||
602 | cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie_val)); | ||
603 | break; | ||
604 | case CMD_ACT_MESH_CONFIG_STOP: | ||
605 | break; | ||
606 | default: | ||
607 | return -1; | ||
608 | } | ||
609 | lbs_deb_cmd("mesh config action %d type %x channel %d SSID %s\n", | ||
610 | action, priv->mesh_tlv, chan, | ||
611 | print_ssid(ssid, priv->mesh_ssid, priv->mesh_ssid_len)); | ||
612 | |||
613 | return __lbs_mesh_config_send(priv, &cmd, action, priv->mesh_tlv); | ||
614 | } | ||
615 | |||
616 | |||
617 | |||
618 | /*************************************************************************** | ||
444 | * Persistent configuration support | 619 | * Persistent configuration support |
445 | */ | 620 | */ |
446 | 621 | ||
diff --git a/drivers/net/wireless/libertas/mesh.h b/drivers/net/wireless/libertas/mesh.h index 23b38ba26cd0..fea9b5d005fc 100644 --- a/drivers/net/wireless/libertas/mesh.h +++ b/drivers/net/wireless/libertas/mesh.h | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | 7 | ||
8 | #include <net/iw_handler.h> | 8 | #include <net/iw_handler.h> |
9 | #include <net/lib80211.h> | ||
9 | 10 | ||
10 | 11 | ||
11 | /* Mesh statistics */ | 12 | /* Mesh statistics */ |
@@ -42,6 +43,16 @@ void lbs_mesh_set_txpd(struct lbs_private *priv, | |||
42 | struct net_device *dev, struct txpd *txpd); | 43 | struct net_device *dev, struct txpd *txpd); |
43 | 44 | ||
44 | 45 | ||
46 | /* Command handling */ | ||
47 | |||
48 | struct cmd_ds_command; | ||
49 | |||
50 | int lbs_cmd_bt_access(struct cmd_ds_command *cmd, | ||
51 | u16 cmd_action, void *pdata_buf); | ||
52 | int lbs_cmd_fwt_access(struct cmd_ds_command *cmd, | ||
53 | u16 cmd_action, void *pdata_buf); | ||
54 | |||
55 | |||
45 | /* Persistent configuration */ | 56 | /* Persistent configuration */ |
46 | 57 | ||
47 | void lbs_persist_config_init(struct net_device *net); | 58 | void lbs_persist_config_init(struct net_device *net); |