aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-12-04 16:25:15 -0500
committerDavid S. Miller <davem@davemloft.net>2009-12-04 16:25:15 -0500
commit8f56874bd7e8bee73ed6a1cf80dcec2753616262 (patch)
treeaebd15dea662ef5efd89402b8fd92fec540a98eb /drivers/net/wireless/libertas
parent47e1c323069bcef0acb8a2b48921688573f5ca63 (diff)
parent159bcfeb9123c91f0dc885a42b6387a98192f896 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
Diffstat (limited to 'drivers/net/wireless/libertas')
-rw-r--r--drivers/net/wireless/libertas/Makefile2
-rw-r--r--drivers/net/wireless/libertas/cmd.c168
-rw-r--r--drivers/net/wireless/libertas/decl.h8
-rw-r--r--drivers/net/wireless/libertas/dev.h12
-rw-r--r--drivers/net/wireless/libertas/ethtool.c84
-rw-r--r--drivers/net/wireless/libertas/main.c357
-rw-r--r--drivers/net/wireless/libertas/mesh.c1141
-rw-r--r--drivers/net/wireless/libertas/mesh.h78
-rw-r--r--drivers/net/wireless/libertas/persistcfg.c453
-rw-r--r--drivers/net/wireless/libertas/rx.c11
-rw-r--r--drivers/net/wireless/libertas/tx.c7
-rw-r--r--drivers/net/wireless/libertas/wext.h5
12 files changed, 1248 insertions, 1078 deletions
diff --git a/drivers/net/wireless/libertas/Makefile b/drivers/net/wireless/libertas/Makefile
index fa37039e0eae..b188cd97a053 100644
--- a/drivers/net/wireless/libertas/Makefile
+++ b/drivers/net/wireless/libertas/Makefile
@@ -5,7 +5,7 @@ libertas-y += cmdresp.o
5libertas-y += debugfs.o 5libertas-y += debugfs.o
6libertas-y += ethtool.o 6libertas-y += ethtool.o
7libertas-y += main.o 7libertas-y += main.o
8libertas-y += persistcfg.o 8libertas-y += mesh.o
9libertas-y += rx.o 9libertas-y += rx.o
10libertas-y += scan.o 10libertas-y += scan.o
11libertas-y += tx.o 11libertas-y += tx.o
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
700static 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
738static 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
760int 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
779static 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
809int 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 */
827int 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
867static void lbs_queue_cmd(struct lbs_private *priv, 699static 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/decl.h b/drivers/net/wireless/libertas/decl.h
index 678f7c9f7503..709ffcad22ad 100644
--- a/drivers/net/wireless/libertas/decl.h
+++ b/drivers/net/wireless/libertas/decl.h
@@ -27,11 +27,6 @@ netdev_tx_t lbs_hard_start_xmit(struct sk_buff *skb,
27int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *); 27int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *);
28 28
29 29
30/* persistcfg.c */
31void lbs_persist_config_init(struct net_device *net);
32void lbs_persist_config_remove(struct net_device *net);
33
34
35/* main.c */ 30/* main.c */
36struct lbs_private *lbs_add_card(void *card, struct device *dmdev); 31struct lbs_private *lbs_add_card(void *card, struct device *dmdev);
37void lbs_remove_card(struct lbs_private *priv); 32void lbs_remove_card(struct lbs_private *priv);
@@ -39,6 +34,9 @@ int lbs_start_card(struct lbs_private *priv);
39void lbs_stop_card(struct lbs_private *priv); 34void lbs_stop_card(struct lbs_private *priv);
40void lbs_host_to_card_done(struct lbs_private *priv); 35void lbs_host_to_card_done(struct lbs_private *priv);
41 36
37int lbs_set_mac_address(struct net_device *dev, void *addr);
38void lbs_set_multicast_list(struct net_device *dev);
39
42int lbs_suspend(struct lbs_private *priv); 40int lbs_suspend(struct lbs_private *priv);
43void lbs_resume(struct lbs_private *priv); 41void lbs_resume(struct lbs_private *priv);
44 42
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index 1a675111300d..6a8d2b291d8c 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -6,6 +6,7 @@
6#ifndef _LBS_DEV_H_ 6#ifndef _LBS_DEV_H_
7#define _LBS_DEV_H_ 7#define _LBS_DEV_H_
8 8
9#include "mesh.h"
9#include "scan.h" 10#include "scan.h"
10#include "assoc.h" 11#include "assoc.h"
11 12
@@ -21,17 +22,6 @@ struct sleep_params {
21 uint16_t sp_reserved; 22 uint16_t sp_reserved;
22}; 23};
23 24
24/* Mesh statistics */
25struct lbs_mesh_stats {
26 u32 fwd_bcast_cnt; /* Fwd: Broadcast counter */
27 u32 fwd_unicast_cnt; /* Fwd: Unicast counter */
28 u32 fwd_drop_ttl; /* Fwd: TTL zero */
29 u32 fwd_drop_rbt; /* Fwd: Recently Broadcasted */
30 u32 fwd_drop_noroute; /* Fwd: No route to Destination */
31 u32 fwd_drop_nobuf; /* Fwd: Run out of internal buffers */
32 u32 drop_blind; /* Rx: Dropped by blinding table */
33 u32 tx_failed_cnt; /* Tx: Failed transmissions */
34};
35 25
36/** Private structure for the MV device */ 26/** Private structure for the MV device */
37struct lbs_private { 27struct lbs_private {
diff --git a/drivers/net/wireless/libertas/ethtool.c b/drivers/net/wireless/libertas/ethtool.c
index 53d56ab83c03..63d020374c2b 100644
--- a/drivers/net/wireless/libertas/ethtool.c
+++ b/drivers/net/wireless/libertas/ethtool.c
@@ -8,17 +8,8 @@
8#include "dev.h" 8#include "dev.h"
9#include "wext.h" 9#include "wext.h"
10#include "cmd.h" 10#include "cmd.h"
11#include "mesh.h"
11 12
12static const char * mesh_stat_strings[]= {
13 "drop_duplicate_bcast",
14 "drop_ttl_zero",
15 "drop_no_fwd_route",
16 "drop_no_buffers",
17 "fwded_unicast_cnt",
18 "fwded_bcast_cnt",
19 "drop_blind_table",
20 "tx_failed_cnt"
21};
22 13
23static void lbs_ethtool_get_drvinfo(struct net_device *dev, 14static void lbs_ethtool_get_drvinfo(struct net_device *dev,
24 struct ethtool_drvinfo *info) 15 struct ethtool_drvinfo *info)
@@ -73,73 +64,6 @@ out:
73 return ret; 64 return ret;
74} 65}
75 66
76static void lbs_ethtool_get_stats(struct net_device *dev,
77 struct ethtool_stats *stats, uint64_t *data)
78{
79 struct lbs_private *priv = dev->ml_priv;
80 struct cmd_ds_mesh_access mesh_access;
81 int ret;
82
83 lbs_deb_enter(LBS_DEB_ETHTOOL);
84
85 /* Get Mesh Statistics */
86 ret = lbs_mesh_access(priv, CMD_ACT_MESH_GET_STATS, &mesh_access);
87
88 if (ret) {
89 memset(data, 0, MESH_STATS_NUM*(sizeof(uint64_t)));
90 return;
91 }
92
93 priv->mstats.fwd_drop_rbt = le32_to_cpu(mesh_access.data[0]);
94 priv->mstats.fwd_drop_ttl = le32_to_cpu(mesh_access.data[1]);
95 priv->mstats.fwd_drop_noroute = le32_to_cpu(mesh_access.data[2]);
96 priv->mstats.fwd_drop_nobuf = le32_to_cpu(mesh_access.data[3]);
97 priv->mstats.fwd_unicast_cnt = le32_to_cpu(mesh_access.data[4]);
98 priv->mstats.fwd_bcast_cnt = le32_to_cpu(mesh_access.data[5]);
99 priv->mstats.drop_blind = le32_to_cpu(mesh_access.data[6]);
100 priv->mstats.tx_failed_cnt = le32_to_cpu(mesh_access.data[7]);
101
102 data[0] = priv->mstats.fwd_drop_rbt;
103 data[1] = priv->mstats.fwd_drop_ttl;
104 data[2] = priv->mstats.fwd_drop_noroute;
105 data[3] = priv->mstats.fwd_drop_nobuf;
106 data[4] = priv->mstats.fwd_unicast_cnt;
107 data[5] = priv->mstats.fwd_bcast_cnt;
108 data[6] = priv->mstats.drop_blind;
109 data[7] = priv->mstats.tx_failed_cnt;
110
111 lbs_deb_enter(LBS_DEB_ETHTOOL);
112}
113
114static int lbs_ethtool_get_sset_count(struct net_device *dev, int sset)
115{
116 struct lbs_private *priv = dev->ml_priv;
117
118 if (sset == ETH_SS_STATS && dev == priv->mesh_dev)
119 return MESH_STATS_NUM;
120
121 return -EOPNOTSUPP;
122}
123
124static void lbs_ethtool_get_strings(struct net_device *dev,
125 uint32_t stringset, uint8_t *s)
126{
127 int i;
128
129 lbs_deb_enter(LBS_DEB_ETHTOOL);
130
131 switch (stringset) {
132 case ETH_SS_STATS:
133 for (i=0; i < MESH_STATS_NUM; i++) {
134 memcpy(s + i * ETH_GSTRING_LEN,
135 mesh_stat_strings[i],
136 ETH_GSTRING_LEN);
137 }
138 break;
139 }
140 lbs_deb_enter(LBS_DEB_ETHTOOL);
141}
142
143static void lbs_ethtool_get_wol(struct net_device *dev, 67static void lbs_ethtool_get_wol(struct net_device *dev,
144 struct ethtool_wolinfo *wol) 68 struct ethtool_wolinfo *wol)
145{ 69{
@@ -190,9 +114,9 @@ const struct ethtool_ops lbs_ethtool_ops = {
190 .get_drvinfo = lbs_ethtool_get_drvinfo, 114 .get_drvinfo = lbs_ethtool_get_drvinfo,
191 .get_eeprom = lbs_ethtool_get_eeprom, 115 .get_eeprom = lbs_ethtool_get_eeprom,
192 .get_eeprom_len = lbs_ethtool_get_eeprom_len, 116 .get_eeprom_len = lbs_ethtool_get_eeprom_len,
193 .get_sset_count = lbs_ethtool_get_sset_count, 117 .get_sset_count = lbs_mesh_ethtool_get_sset_count,
194 .get_ethtool_stats = lbs_ethtool_get_stats, 118 .get_ethtool_stats = lbs_mesh_ethtool_get_stats,
195 .get_strings = lbs_ethtool_get_strings, 119 .get_strings = lbs_mesh_ethtool_get_strings,
196 .get_wol = lbs_ethtool_get_wol, 120 .get_wol = lbs_ethtool_get_wol,
197 .set_wol = lbs_ethtool_set_wol, 121 .set_wol = lbs_ethtool_set_wol,
198}; 122};
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 01f46cf288d7..db38a5a719fa 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -94,107 +94,9 @@ u8 lbs_data_rate_to_fw_index(u32 rate)
94 return 0; 94 return 0;
95} 95}
96 96
97/**
98 * Attributes exported through sysfs
99 */
100
101/**
102 * @brief Get function for sysfs attribute anycast_mask
103 */
104static ssize_t lbs_anycast_get(struct device *dev,
105 struct device_attribute *attr, char * buf)
106{
107 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
108 struct cmd_ds_mesh_access mesh_access;
109 int ret;
110
111 memset(&mesh_access, 0, sizeof(mesh_access));
112
113 ret = lbs_mesh_access(priv, CMD_ACT_MESH_GET_ANYCAST, &mesh_access);
114 if (ret)
115 return ret;
116
117 return snprintf(buf, 12, "0x%X\n", le32_to_cpu(mesh_access.data[0]));
118}
119
120/**
121 * @brief Set function for sysfs attribute anycast_mask
122 */
123static ssize_t lbs_anycast_set(struct device *dev,
124 struct device_attribute *attr, const char * buf, size_t count)
125{
126 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
127 struct cmd_ds_mesh_access mesh_access;
128 uint32_t datum;
129 int ret;
130
131 memset(&mesh_access, 0, sizeof(mesh_access));
132 sscanf(buf, "%x", &datum);
133 mesh_access.data[0] = cpu_to_le32(datum);
134
135 ret = lbs_mesh_access(priv, CMD_ACT_MESH_SET_ANYCAST, &mesh_access);
136 if (ret)
137 return ret;
138
139 return strlen(buf);
140}
141
142/**
143 * @brief Get function for sysfs attribute prb_rsp_limit
144 */
145static ssize_t lbs_prb_rsp_limit_get(struct device *dev,
146 struct device_attribute *attr, char *buf)
147{
148 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
149 struct cmd_ds_mesh_access mesh_access;
150 int ret;
151 u32 retry_limit;
152
153 memset(&mesh_access, 0, sizeof(mesh_access));
154 mesh_access.data[0] = cpu_to_le32(CMD_ACT_GET);
155
156 ret = lbs_mesh_access(priv, CMD_ACT_MESH_SET_GET_PRB_RSP_LIMIT,
157 &mesh_access);
158 if (ret)
159 return ret;
160
161 retry_limit = le32_to_cpu(mesh_access.data[1]);
162 return snprintf(buf, 10, "%d\n", retry_limit);
163}
164
165/**
166 * @brief Set function for sysfs attribute prb_rsp_limit
167 */
168static ssize_t lbs_prb_rsp_limit_set(struct device *dev,
169 struct device_attribute *attr, const char *buf, size_t count)
170{
171 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
172 struct cmd_ds_mesh_access mesh_access;
173 int ret;
174 unsigned long retry_limit;
175
176 memset(&mesh_access, 0, sizeof(mesh_access));
177 mesh_access.data[0] = cpu_to_le32(CMD_ACT_SET);
178
179 if (!strict_strtoul(buf, 10, &retry_limit))
180 return -ENOTSUPP;
181 if (retry_limit > 15)
182 return -ENOTSUPP;
183
184 mesh_access.data[1] = cpu_to_le32(retry_limit);
185
186 ret = lbs_mesh_access(priv, CMD_ACT_MESH_SET_GET_PRB_RSP_LIMIT,
187 &mesh_access);
188 if (ret)
189 return ret;
190
191 return strlen(buf);
192}
193 97
194static int lbs_add_rtap(struct lbs_private *priv); 98static int lbs_add_rtap(struct lbs_private *priv);
195static void lbs_remove_rtap(struct lbs_private *priv); 99static void lbs_remove_rtap(struct lbs_private *priv);
196static int lbs_add_mesh(struct lbs_private *priv);
197static void lbs_remove_mesh(struct lbs_private *priv);
198 100
199 101
200/** 102/**
@@ -260,74 +162,7 @@ static ssize_t lbs_rtap_set(struct device *dev,
260static DEVICE_ATTR(lbs_rtap, 0644, lbs_rtap_get, lbs_rtap_set ); 162static DEVICE_ATTR(lbs_rtap, 0644, lbs_rtap_get, lbs_rtap_set );
261 163
262/** 164/**
263 * Get function for sysfs attribute mesh 165 * @brief This function opens the ethX interface
264 */
265static ssize_t lbs_mesh_get(struct device *dev,
266 struct device_attribute *attr, char * buf)
267{
268 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
269 return snprintf(buf, 5, "0x%X\n", !!priv->mesh_dev);
270}
271
272/**
273 * Set function for sysfs attribute mesh
274 */
275static ssize_t lbs_mesh_set(struct device *dev,
276 struct device_attribute *attr, const char * buf, size_t count)
277{
278 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
279 int enable;
280 int ret, action = CMD_ACT_MESH_CONFIG_STOP;
281
282 sscanf(buf, "%x", &enable);
283 enable = !!enable;
284 if (enable == !!priv->mesh_dev)
285 return count;
286 if (enable)
287 action = CMD_ACT_MESH_CONFIG_START;
288 ret = lbs_mesh_config(priv, action, priv->channel);
289 if (ret)
290 return ret;
291
292 if (enable)
293 lbs_add_mesh(priv);
294 else
295 lbs_remove_mesh(priv);
296
297 return count;
298}
299
300/**
301 * lbs_mesh attribute to be exported per ethX interface
302 * through sysfs (/sys/class/net/ethX/lbs_mesh)
303 */
304static DEVICE_ATTR(lbs_mesh, 0644, lbs_mesh_get, lbs_mesh_set);
305
306/**
307 * anycast_mask attribute to be exported per mshX interface
308 * through sysfs (/sys/class/net/mshX/anycast_mask)
309 */
310static DEVICE_ATTR(anycast_mask, 0644, lbs_anycast_get, lbs_anycast_set);
311
312/**
313 * prb_rsp_limit attribute to be exported per mshX interface
314 * through sysfs (/sys/class/net/mshX/prb_rsp_limit)
315 */
316static DEVICE_ATTR(prb_rsp_limit, 0644, lbs_prb_rsp_limit_get,
317 lbs_prb_rsp_limit_set);
318
319static struct attribute *lbs_mesh_sysfs_entries[] = {
320 &dev_attr_anycast_mask.attr,
321 &dev_attr_prb_rsp_limit.attr,
322 NULL,
323};
324
325static struct attribute_group lbs_mesh_attr_group = {
326 .attrs = lbs_mesh_sysfs_entries,
327};
328
329/**
330 * @brief This function opens the ethX or mshX interface
331 * 166 *
332 * @param dev A pointer to net_device structure 167 * @param dev A pointer to net_device structure
333 * @return 0 or -EBUSY if monitor mode active 168 * @return 0 or -EBUSY if monitor mode active
@@ -346,18 +181,12 @@ static int lbs_dev_open(struct net_device *dev)
346 goto out; 181 goto out;
347 } 182 }
348 183
349 if (dev == priv->mesh_dev) { 184 priv->infra_open = 1;
350 priv->mesh_open = 1;
351 priv->mesh_connect_status = LBS_CONNECTED;
352 netif_carrier_on(dev);
353 } else {
354 priv->infra_open = 1;
355 185
356 if (priv->connect_status == LBS_CONNECTED) 186 if (priv->connect_status == LBS_CONNECTED)
357 netif_carrier_on(dev); 187 netif_carrier_on(dev);
358 else 188 else
359 netif_carrier_off(dev); 189 netif_carrier_off(dev);
360 }
361 190
362 if (!priv->tx_pending_len) 191 if (!priv->tx_pending_len)
363 netif_wake_queue(dev); 192 netif_wake_queue(dev);
@@ -369,33 +198,6 @@ static int lbs_dev_open(struct net_device *dev)
369} 198}
370 199
371/** 200/**
372 * @brief This function closes the mshX interface
373 *
374 * @param dev A pointer to net_device structure
375 * @return 0
376 */
377static int lbs_mesh_stop(struct net_device *dev)
378{
379 struct lbs_private *priv = dev->ml_priv;
380
381 lbs_deb_enter(LBS_DEB_MESH);
382 spin_lock_irq(&priv->driver_lock);
383
384 priv->mesh_open = 0;
385 priv->mesh_connect_status = LBS_DISCONNECTED;
386
387 netif_stop_queue(dev);
388 netif_carrier_off(dev);
389
390 spin_unlock_irq(&priv->driver_lock);
391
392 schedule_work(&priv->mcast_work);
393
394 lbs_deb_leave(LBS_DEB_MESH);
395 return 0;
396}
397
398/**
399 * @brief This function closes the ethX interface 201 * @brief This function closes the ethX interface
400 * 202 *
401 * @param dev A pointer to net_device structure 203 * @param dev A pointer to net_device structure
@@ -466,7 +268,7 @@ void lbs_host_to_card_done(struct lbs_private *priv)
466} 268}
467EXPORT_SYMBOL_GPL(lbs_host_to_card_done); 269EXPORT_SYMBOL_GPL(lbs_host_to_card_done);
468 270
469static int lbs_set_mac_address(struct net_device *dev, void *addr) 271int lbs_set_mac_address(struct net_device *dev, void *addr)
470{ 272{
471 int ret = 0; 273 int ret = 0;
472 struct lbs_private *priv = dev->ml_priv; 274 struct lbs_private *priv = dev->ml_priv;
@@ -600,7 +402,7 @@ static void lbs_set_mcast_worker(struct work_struct *work)
600 lbs_deb_leave(LBS_DEB_NET); 402 lbs_deb_leave(LBS_DEB_NET);
601} 403}
602 404
603static void lbs_set_multicast_list(struct net_device *dev) 405void lbs_set_multicast_list(struct net_device *dev)
604{ 406{
605 struct lbs_private *priv = dev->ml_priv; 407 struct lbs_private *priv = dev->ml_priv;
606 408
@@ -1177,7 +979,6 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
1177 979
1178 980
1179 priv->card = card; 981 priv->card = card;
1180 priv->mesh_open = 0;
1181 priv->infra_open = 0; 982 priv->infra_open = 0;
1182 983
1183 984
@@ -1198,6 +999,7 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
1198 INIT_WORK(&priv->mcast_work, lbs_set_mcast_worker); 999 INIT_WORK(&priv->mcast_work, lbs_set_mcast_worker);
1199 INIT_WORK(&priv->sync_channel, lbs_sync_channel_worker); 1000 INIT_WORK(&priv->sync_channel, lbs_sync_channel_worker);
1200 1001
1002 priv->mesh_open = 0;
1201 sprintf(priv->mesh_ssid, "mesh"); 1003 sprintf(priv->mesh_ssid, "mesh");
1202 priv->mesh_ssid_len = 4; 1004 priv->mesh_ssid_len = 4;
1203 1005
@@ -1292,50 +1094,12 @@ int lbs_start_card(struct lbs_private *priv)
1292 1094
1293 lbs_update_channel(priv); 1095 lbs_update_channel(priv);
1294 1096
1295 /* Check mesh FW version and appropriately send the mesh start 1097 /*
1296 * command 1098 * While rtap isn't related to mesh, only mesh-enabled
1099 * firmware implements the rtap functionality via
1100 * CMD_802_11_MONITOR_MODE.
1297 */ 1101 */
1298 if (priv->mesh_fw_ver == MESH_FW_OLD) { 1102 if (lbs_init_mesh(priv)) {
1299 /* Enable mesh, if supported, and work out which TLV it uses.
1300 0x100 + 291 is an unofficial value used in 5.110.20.pXX
1301 0x100 + 37 is the official value used in 5.110.21.pXX
1302 but we check them in that order because 20.pXX doesn't
1303 give an error -- it just silently fails. */
1304
1305 /* 5.110.20.pXX firmware will fail the command if the channel
1306 doesn't match the existing channel. But only if the TLV
1307 is correct. If the channel is wrong, _BOTH_ versions will
1308 give an error to 0x100+291, and allow 0x100+37 to succeed.
1309 It's just that 5.110.20.pXX will not have done anything
1310 useful */
1311
1312 priv->mesh_tlv = TLV_TYPE_OLD_MESH_ID;
1313 if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
1314 priv->channel)) {
1315 priv->mesh_tlv = TLV_TYPE_MESH_ID;
1316 if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
1317 priv->channel))
1318 priv->mesh_tlv = 0;
1319 }
1320 } else if (priv->mesh_fw_ver == MESH_FW_NEW) {
1321 /* 10.0.0.pXX new firmwares should succeed with TLV
1322 * 0x100+37; Do not invoke command with old TLV.
1323 */
1324 priv->mesh_tlv = TLV_TYPE_MESH_ID;
1325 if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
1326 priv->channel))
1327 priv->mesh_tlv = 0;
1328 }
1329 if (priv->mesh_tlv) {
1330 lbs_add_mesh(priv);
1331
1332 if (device_create_file(&dev->dev, &dev_attr_lbs_mesh))
1333 lbs_pr_err("cannot register lbs_mesh attribute\n");
1334
1335 /* While rtap isn't related to mesh, only mesh-enabled
1336 * firmware implements the rtap functionality via
1337 * CMD_802_11_MONITOR_MODE.
1338 */
1339 if (device_create_file(&dev->dev, &dev_attr_lbs_rtap)) 1103 if (device_create_file(&dev->dev, &dev_attr_lbs_rtap))
1340 lbs_pr_err("cannot register lbs_rtap attribute\n"); 1104 lbs_pr_err("cannot register lbs_rtap attribute\n");
1341 } 1105 }
@@ -1369,10 +1133,8 @@ void lbs_stop_card(struct lbs_private *priv)
1369 netif_carrier_off(dev); 1133 netif_carrier_off(dev);
1370 1134
1371 lbs_debugfs_remove_one(priv); 1135 lbs_debugfs_remove_one(priv);
1372 if (priv->mesh_tlv) { 1136 if (lbs_deinit_mesh(priv))
1373 device_remove_file(&dev->dev, &dev_attr_lbs_mesh);
1374 device_remove_file(&dev->dev, &dev_attr_lbs_rtap); 1137 device_remove_file(&dev->dev, &dev_attr_lbs_rtap);
1375 }
1376 1138
1377 /* Delete the timeout of the currently processing command */ 1139 /* Delete the timeout of the currently processing command */
1378 del_timer_sync(&priv->command_timer); 1140 del_timer_sync(&priv->command_timer);
@@ -1405,95 +1167,6 @@ out:
1405EXPORT_SYMBOL_GPL(lbs_stop_card); 1167EXPORT_SYMBOL_GPL(lbs_stop_card);
1406 1168
1407 1169
1408static const struct net_device_ops mesh_netdev_ops = {
1409 .ndo_open = lbs_dev_open,
1410 .ndo_stop = lbs_mesh_stop,
1411 .ndo_start_xmit = lbs_hard_start_xmit,
1412 .ndo_set_mac_address = lbs_set_mac_address,
1413 .ndo_set_multicast_list = lbs_set_multicast_list,
1414};
1415
1416/**
1417 * @brief This function adds mshX interface
1418 *
1419 * @param priv A pointer to the struct lbs_private structure
1420 * @return 0 if successful, -X otherwise
1421 */
1422static int lbs_add_mesh(struct lbs_private *priv)
1423{
1424 struct net_device *mesh_dev = NULL;
1425 int ret = 0;
1426
1427 lbs_deb_enter(LBS_DEB_MESH);
1428
1429 /* Allocate a virtual mesh device */
1430 if (!(mesh_dev = alloc_netdev(0, "msh%d", ether_setup))) {
1431 lbs_deb_mesh("init mshX device failed\n");
1432 ret = -ENOMEM;
1433 goto done;
1434 }
1435 mesh_dev->ml_priv = priv;
1436 priv->mesh_dev = mesh_dev;
1437
1438 mesh_dev->netdev_ops = &mesh_netdev_ops;
1439 mesh_dev->ethtool_ops = &lbs_ethtool_ops;
1440 memcpy(mesh_dev->dev_addr, priv->dev->dev_addr,
1441 sizeof(priv->dev->dev_addr));
1442
1443 SET_NETDEV_DEV(priv->mesh_dev, priv->dev->dev.parent);
1444
1445#ifdef WIRELESS_EXT
1446 mesh_dev->wireless_handlers = (struct iw_handler_def *)&mesh_handler_def;
1447#endif
1448 mesh_dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
1449 /* Register virtual mesh interface */
1450 ret = register_netdev(mesh_dev);
1451 if (ret) {
1452 lbs_pr_err("cannot register mshX virtual interface\n");
1453 goto err_free;
1454 }
1455
1456 ret = sysfs_create_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
1457 if (ret)
1458 goto err_unregister;
1459
1460 lbs_persist_config_init(mesh_dev);
1461
1462 /* Everything successful */
1463 ret = 0;
1464 goto done;
1465
1466err_unregister:
1467 unregister_netdev(mesh_dev);
1468
1469err_free:
1470 free_netdev(mesh_dev);
1471
1472done:
1473 lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret);
1474 return ret;
1475}
1476
1477static void lbs_remove_mesh(struct lbs_private *priv)
1478{
1479 struct net_device *mesh_dev;
1480
1481
1482 mesh_dev = priv->mesh_dev;
1483 if (!mesh_dev)
1484 return;
1485
1486 lbs_deb_enter(LBS_DEB_MESH);
1487 netif_stop_queue(mesh_dev);
1488 netif_carrier_off(mesh_dev);
1489 sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
1490 lbs_persist_config_remove(mesh_dev);
1491 unregister_netdev(mesh_dev);
1492 priv->mesh_dev = NULL;
1493 free_netdev(mesh_dev);
1494 lbs_deb_leave(LBS_DEB_MESH);
1495}
1496
1497void lbs_queue_event(struct lbs_private *priv, u32 event) 1170void lbs_queue_event(struct lbs_private *priv, u32 event)
1498{ 1171{
1499 unsigned long flags; 1172 unsigned long flags;
diff --git a/drivers/net/wireless/libertas/mesh.c b/drivers/net/wireless/libertas/mesh.c
new file mode 100644
index 000000000000..2f91c9b808af
--- /dev/null
+++ b/drivers/net/wireless/libertas/mesh.c
@@ -0,0 +1,1141 @@
1#include <linux/moduleparam.h>
2#include <linux/delay.h>
3#include <linux/etherdevice.h>
4#include <linux/netdevice.h>
5#include <linux/if_arp.h>
6#include <linux/kthread.h>
7#include <linux/kfifo.h>
8
9#include "mesh.h"
10#include "decl.h"
11#include "cmd.h"
12
13
14/***************************************************************************
15 * Mesh sysfs support
16 */
17
18/**
19 * Attributes exported through sysfs
20 */
21
22/**
23 * @brief Get function for sysfs attribute anycast_mask
24 */
25static ssize_t lbs_anycast_get(struct device *dev,
26 struct device_attribute *attr, char * buf)
27{
28 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
29 struct cmd_ds_mesh_access mesh_access;
30 int ret;
31
32 memset(&mesh_access, 0, sizeof(mesh_access));
33
34 ret = lbs_mesh_access(priv, CMD_ACT_MESH_GET_ANYCAST, &mesh_access);
35 if (ret)
36 return ret;
37
38 return snprintf(buf, 12, "0x%X\n", le32_to_cpu(mesh_access.data[0]));
39}
40
41/**
42 * @brief Set function for sysfs attribute anycast_mask
43 */
44static ssize_t lbs_anycast_set(struct device *dev,
45 struct device_attribute *attr, const char * buf, size_t count)
46{
47 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
48 struct cmd_ds_mesh_access mesh_access;
49 uint32_t datum;
50 int ret;
51
52 memset(&mesh_access, 0, sizeof(mesh_access));
53 sscanf(buf, "%x", &datum);
54 mesh_access.data[0] = cpu_to_le32(datum);
55
56 ret = lbs_mesh_access(priv, CMD_ACT_MESH_SET_ANYCAST, &mesh_access);
57 if (ret)
58 return ret;
59
60 return strlen(buf);
61}
62
63/**
64 * @brief Get function for sysfs attribute prb_rsp_limit
65 */
66static ssize_t lbs_prb_rsp_limit_get(struct device *dev,
67 struct device_attribute *attr, char *buf)
68{
69 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
70 struct cmd_ds_mesh_access mesh_access;
71 int ret;
72 u32 retry_limit;
73
74 memset(&mesh_access, 0, sizeof(mesh_access));
75 mesh_access.data[0] = cpu_to_le32(CMD_ACT_GET);
76
77 ret = lbs_mesh_access(priv, CMD_ACT_MESH_SET_GET_PRB_RSP_LIMIT,
78 &mesh_access);
79 if (ret)
80 return ret;
81
82 retry_limit = le32_to_cpu(mesh_access.data[1]);
83 return snprintf(buf, 10, "%d\n", retry_limit);
84}
85
86/**
87 * @brief Set function for sysfs attribute prb_rsp_limit
88 */
89static ssize_t lbs_prb_rsp_limit_set(struct device *dev,
90 struct device_attribute *attr, const char *buf, size_t count)
91{
92 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
93 struct cmd_ds_mesh_access mesh_access;
94 int ret;
95 unsigned long retry_limit;
96
97 memset(&mesh_access, 0, sizeof(mesh_access));
98 mesh_access.data[0] = cpu_to_le32(CMD_ACT_SET);
99
100 if (!strict_strtoul(buf, 10, &retry_limit))
101 return -ENOTSUPP;
102 if (retry_limit > 15)
103 return -ENOTSUPP;
104
105 mesh_access.data[1] = cpu_to_le32(retry_limit);
106
107 ret = lbs_mesh_access(priv, CMD_ACT_MESH_SET_GET_PRB_RSP_LIMIT,
108 &mesh_access);
109 if (ret)
110 return ret;
111
112 return strlen(buf);
113}
114
115/**
116 * Get function for sysfs attribute mesh
117 */
118static ssize_t lbs_mesh_get(struct device *dev,
119 struct device_attribute *attr, char * buf)
120{
121 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
122 return snprintf(buf, 5, "0x%X\n", !!priv->mesh_dev);
123}
124
125/**
126 * Set function for sysfs attribute mesh
127 */
128static ssize_t lbs_mesh_set(struct device *dev,
129 struct device_attribute *attr, const char * buf, size_t count)
130{
131 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
132 int enable;
133 int ret, action = CMD_ACT_MESH_CONFIG_STOP;
134
135 sscanf(buf, "%x", &enable);
136 enable = !!enable;
137 if (enable == !!priv->mesh_dev)
138 return count;
139 if (enable)
140 action = CMD_ACT_MESH_CONFIG_START;
141 ret = lbs_mesh_config(priv, action, priv->channel);
142 if (ret)
143 return ret;
144
145 if (enable)
146 lbs_add_mesh(priv);
147 else
148 lbs_remove_mesh(priv);
149
150 return count;
151}
152
153/**
154 * lbs_mesh attribute to be exported per ethX interface
155 * through sysfs (/sys/class/net/ethX/lbs_mesh)
156 */
157static DEVICE_ATTR(lbs_mesh, 0644, lbs_mesh_get, lbs_mesh_set);
158
159/**
160 * anycast_mask attribute to be exported per mshX interface
161 * through sysfs (/sys/class/net/mshX/anycast_mask)
162 */
163static DEVICE_ATTR(anycast_mask, 0644, lbs_anycast_get, lbs_anycast_set);
164
165/**
166 * prb_rsp_limit attribute to be exported per mshX interface
167 * through sysfs (/sys/class/net/mshX/prb_rsp_limit)
168 */
169static DEVICE_ATTR(prb_rsp_limit, 0644, lbs_prb_rsp_limit_get,
170 lbs_prb_rsp_limit_set);
171
172static struct attribute *lbs_mesh_sysfs_entries[] = {
173 &dev_attr_anycast_mask.attr,
174 &dev_attr_prb_rsp_limit.attr,
175 NULL,
176};
177
178static struct attribute_group lbs_mesh_attr_group = {
179 .attrs = lbs_mesh_sysfs_entries,
180};
181
182
183
184/***************************************************************************
185 * Initializing and starting, stopping mesh
186 */
187
188/*
189 * Check mesh FW version and appropriately send the mesh start
190 * command
191 */
192int lbs_init_mesh(struct lbs_private *priv)
193{
194 struct net_device *dev = priv->dev;
195 int ret = 0;
196
197 lbs_deb_enter(LBS_DEB_MESH);
198
199 if (priv->mesh_fw_ver == MESH_FW_OLD) {
200 /* Enable mesh, if supported, and work out which TLV it uses.
201 0x100 + 291 is an unofficial value used in 5.110.20.pXX
202 0x100 + 37 is the official value used in 5.110.21.pXX
203 but we check them in that order because 20.pXX doesn't
204 give an error -- it just silently fails. */
205
206 /* 5.110.20.pXX firmware will fail the command if the channel
207 doesn't match the existing channel. But only if the TLV
208 is correct. If the channel is wrong, _BOTH_ versions will
209 give an error to 0x100+291, and allow 0x100+37 to succeed.
210 It's just that 5.110.20.pXX will not have done anything
211 useful */
212
213 priv->mesh_tlv = TLV_TYPE_OLD_MESH_ID;
214 if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
215 priv->channel)) {
216 priv->mesh_tlv = TLV_TYPE_MESH_ID;
217 if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
218 priv->channel))
219 priv->mesh_tlv = 0;
220 }
221 } else if (priv->mesh_fw_ver == MESH_FW_NEW) {
222 /* 10.0.0.pXX new firmwares should succeed with TLV
223 * 0x100+37; Do not invoke command with old TLV.
224 */
225 priv->mesh_tlv = TLV_TYPE_MESH_ID;
226 if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
227 priv->channel))
228 priv->mesh_tlv = 0;
229 }
230 if (priv->mesh_tlv) {
231 lbs_add_mesh(priv);
232
233 if (device_create_file(&dev->dev, &dev_attr_lbs_mesh))
234 lbs_pr_err("cannot register lbs_mesh attribute\n");
235
236 ret = 1;
237 }
238
239 lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret);
240 return ret;
241}
242
243
244int lbs_deinit_mesh(struct lbs_private *priv)
245{
246 struct net_device *dev = priv->dev;
247 int ret = 0;
248
249 lbs_deb_enter(LBS_DEB_MESH);
250
251 if (priv->mesh_tlv) {
252 device_remove_file(&dev->dev, &dev_attr_lbs_mesh);
253 ret = 1;
254 }
255
256 lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret);
257 return ret;
258}
259
260
261/**
262 * @brief This function closes the mshX interface
263 *
264 * @param dev A pointer to net_device structure
265 * @return 0
266 */
267static int lbs_mesh_stop(struct net_device *dev)
268{
269 struct lbs_private *priv = dev->ml_priv;
270
271 lbs_deb_enter(LBS_DEB_MESH);
272 spin_lock_irq(&priv->driver_lock);
273
274 priv->mesh_open = 0;
275 priv->mesh_connect_status = LBS_DISCONNECTED;
276
277 netif_stop_queue(dev);
278 netif_carrier_off(dev);
279
280 spin_unlock_irq(&priv->driver_lock);
281
282 schedule_work(&priv->mcast_work);
283
284 lbs_deb_leave(LBS_DEB_MESH);
285 return 0;
286}
287
288/**
289 * @brief This function opens the mshX interface
290 *
291 * @param dev A pointer to net_device structure
292 * @return 0 or -EBUSY if monitor mode active
293 */
294static int lbs_mesh_dev_open(struct net_device *dev)
295{
296 struct lbs_private *priv = dev->ml_priv;
297 int ret = 0;
298
299 lbs_deb_enter(LBS_DEB_NET);
300
301 spin_lock_irq(&priv->driver_lock);
302
303 if (priv->monitormode) {
304 ret = -EBUSY;
305 goto out;
306 }
307
308 priv->mesh_open = 1;
309 priv->mesh_connect_status = LBS_CONNECTED;
310 netif_carrier_on(dev);
311
312 if (!priv->tx_pending_len)
313 netif_wake_queue(dev);
314 out:
315
316 spin_unlock_irq(&priv->driver_lock);
317 lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret);
318 return ret;
319}
320
321static const struct net_device_ops mesh_netdev_ops = {
322 .ndo_open = lbs_mesh_dev_open,
323 .ndo_stop = lbs_mesh_stop,
324 .ndo_start_xmit = lbs_hard_start_xmit,
325 .ndo_set_mac_address = lbs_set_mac_address,
326 .ndo_set_multicast_list = lbs_set_multicast_list,
327};
328
329/**
330 * @brief This function adds mshX interface
331 *
332 * @param priv A pointer to the struct lbs_private structure
333 * @return 0 if successful, -X otherwise
334 */
335int lbs_add_mesh(struct lbs_private *priv)
336{
337 struct net_device *mesh_dev = NULL;
338 int ret = 0;
339
340 lbs_deb_enter(LBS_DEB_MESH);
341
342 /* Allocate a virtual mesh device */
343 mesh_dev = alloc_netdev(0, "msh%d", ether_setup);
344 if (!mesh_dev) {
345 lbs_deb_mesh("init mshX device failed\n");
346 ret = -ENOMEM;
347 goto done;
348 }
349 mesh_dev->ml_priv = priv;
350 priv->mesh_dev = mesh_dev;
351
352 mesh_dev->netdev_ops = &mesh_netdev_ops;
353 mesh_dev->ethtool_ops = &lbs_ethtool_ops;
354 memcpy(mesh_dev->dev_addr, priv->dev->dev_addr,
355 sizeof(priv->dev->dev_addr));
356
357 SET_NETDEV_DEV(priv->mesh_dev, priv->dev->dev.parent);
358
359#ifdef WIRELESS_EXT
360 mesh_dev->wireless_handlers = &mesh_handler_def;
361#endif
362 mesh_dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
363 /* Register virtual mesh interface */
364 ret = register_netdev(mesh_dev);
365 if (ret) {
366 lbs_pr_err("cannot register mshX virtual interface\n");
367 goto err_free;
368 }
369
370 ret = sysfs_create_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
371 if (ret)
372 goto err_unregister;
373
374 lbs_persist_config_init(mesh_dev);
375
376 /* Everything successful */
377 ret = 0;
378 goto done;
379
380err_unregister:
381 unregister_netdev(mesh_dev);
382
383err_free:
384 free_netdev(mesh_dev);
385
386done:
387 lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret);
388 return ret;
389}
390
391void lbs_remove_mesh(struct lbs_private *priv)
392{
393 struct net_device *mesh_dev;
394
395 mesh_dev = priv->mesh_dev;
396 if (!mesh_dev)
397 return;
398
399 lbs_deb_enter(LBS_DEB_MESH);
400 netif_stop_queue(mesh_dev);
401 netif_carrier_off(mesh_dev);
402 sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
403 lbs_persist_config_remove(mesh_dev);
404 unregister_netdev(mesh_dev);
405 priv->mesh_dev = NULL;
406 free_netdev(mesh_dev);
407 lbs_deb_leave(LBS_DEB_MESH);
408}
409
410
411
412/***************************************************************************
413 * Sending and receiving
414 */
415struct net_device *lbs_mesh_set_dev(struct lbs_private *priv,
416 struct net_device *dev, struct rxpd *rxpd)
417{
418 if (priv->mesh_dev) {
419 if (priv->mesh_fw_ver == MESH_FW_OLD) {
420 if (rxpd->rx_control & RxPD_MESH_FRAME)
421 dev = priv->mesh_dev;
422 } else if (priv->mesh_fw_ver == MESH_FW_NEW) {
423 if (rxpd->u.bss.bss_num == MESH_IFACE_ID)
424 dev = priv->mesh_dev;
425 }
426 }
427 return dev;
428}
429
430
431void lbs_mesh_set_txpd(struct lbs_private *priv,
432 struct net_device *dev, struct txpd *txpd)
433{
434 if (dev == priv->mesh_dev) {
435 if (priv->mesh_fw_ver == MESH_FW_OLD)
436 txpd->tx_control |= cpu_to_le32(TxPD_MESH_FRAME);
437 else if (priv->mesh_fw_ver == MESH_FW_NEW)
438 txpd->u.bss.bss_num = MESH_IFACE_ID;
439 }
440}
441
442
443/***************************************************************************
444 * Mesh command handling
445 */
446
447int 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
487int 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
509int 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
528static 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
558int 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 */
576int 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/***************************************************************************
619 * Persistent configuration support
620 */
621
622static int mesh_get_default_parameters(struct device *dev,
623 struct mrvl_mesh_defaults *defs)
624{
625 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
626 struct cmd_ds_mesh_config cmd;
627 int ret;
628
629 memset(&cmd, 0, sizeof(struct cmd_ds_mesh_config));
630 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_GET,
631 CMD_TYPE_MESH_GET_DEFAULTS);
632
633 if (ret)
634 return -EOPNOTSUPP;
635
636 memcpy(defs, &cmd.data[0], sizeof(struct mrvl_mesh_defaults));
637
638 return 0;
639}
640
641/**
642 * @brief Get function for sysfs attribute bootflag
643 */
644static ssize_t bootflag_get(struct device *dev,
645 struct device_attribute *attr, char *buf)
646{
647 struct mrvl_mesh_defaults defs;
648 int ret;
649
650 ret = mesh_get_default_parameters(dev, &defs);
651
652 if (ret)
653 return ret;
654
655 return snprintf(buf, 12, "%d\n", le32_to_cpu(defs.bootflag));
656}
657
658/**
659 * @brief Set function for sysfs attribute bootflag
660 */
661static ssize_t bootflag_set(struct device *dev, struct device_attribute *attr,
662 const char *buf, size_t count)
663{
664 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
665 struct cmd_ds_mesh_config cmd;
666 uint32_t datum;
667 int ret;
668
669 memset(&cmd, 0, sizeof(cmd));
670 ret = sscanf(buf, "%d", &datum);
671 if ((ret != 1) || (datum > 1))
672 return -EINVAL;
673
674 *((__le32 *)&cmd.data[0]) = cpu_to_le32(!!datum);
675 cmd.length = cpu_to_le16(sizeof(uint32_t));
676 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
677 CMD_TYPE_MESH_SET_BOOTFLAG);
678 if (ret)
679 return ret;
680
681 return strlen(buf);
682}
683
684/**
685 * @brief Get function for sysfs attribute boottime
686 */
687static ssize_t boottime_get(struct device *dev,
688 struct device_attribute *attr, char *buf)
689{
690 struct mrvl_mesh_defaults defs;
691 int ret;
692
693 ret = mesh_get_default_parameters(dev, &defs);
694
695 if (ret)
696 return ret;
697
698 return snprintf(buf, 12, "%d\n", defs.boottime);
699}
700
701/**
702 * @brief Set function for sysfs attribute boottime
703 */
704static ssize_t boottime_set(struct device *dev,
705 struct device_attribute *attr, const char *buf, size_t count)
706{
707 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
708 struct cmd_ds_mesh_config cmd;
709 uint32_t datum;
710 int ret;
711
712 memset(&cmd, 0, sizeof(cmd));
713 ret = sscanf(buf, "%d", &datum);
714 if ((ret != 1) || (datum > 255))
715 return -EINVAL;
716
717 /* A too small boot time will result in the device booting into
718 * standalone (no-host) mode before the host can take control of it,
719 * so the change will be hard to revert. This may be a desired
720 * feature (e.g to configure a very fast boot time for devices that
721 * will not be attached to a host), but dangerous. So I'm enforcing a
722 * lower limit of 20 seconds: remove and recompile the driver if this
723 * does not work for you.
724 */
725 datum = (datum < 20) ? 20 : datum;
726 cmd.data[0] = datum;
727 cmd.length = cpu_to_le16(sizeof(uint8_t));
728 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
729 CMD_TYPE_MESH_SET_BOOTTIME);
730 if (ret)
731 return ret;
732
733 return strlen(buf);
734}
735
736/**
737 * @brief Get function for sysfs attribute channel
738 */
739static ssize_t channel_get(struct device *dev,
740 struct device_attribute *attr, char *buf)
741{
742 struct mrvl_mesh_defaults defs;
743 int ret;
744
745 ret = mesh_get_default_parameters(dev, &defs);
746
747 if (ret)
748 return ret;
749
750 return snprintf(buf, 12, "%d\n", le16_to_cpu(defs.channel));
751}
752
753/**
754 * @brief Set function for sysfs attribute channel
755 */
756static ssize_t channel_set(struct device *dev, struct device_attribute *attr,
757 const char *buf, size_t count)
758{
759 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
760 struct cmd_ds_mesh_config cmd;
761 uint32_t datum;
762 int ret;
763
764 memset(&cmd, 0, sizeof(cmd));
765 ret = sscanf(buf, "%d", &datum);
766 if (ret != 1 || datum < 1 || datum > 11)
767 return -EINVAL;
768
769 *((__le16 *)&cmd.data[0]) = cpu_to_le16(datum);
770 cmd.length = cpu_to_le16(sizeof(uint16_t));
771 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
772 CMD_TYPE_MESH_SET_DEF_CHANNEL);
773 if (ret)
774 return ret;
775
776 return strlen(buf);
777}
778
779/**
780 * @brief Get function for sysfs attribute mesh_id
781 */
782static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr,
783 char *buf)
784{
785 struct mrvl_mesh_defaults defs;
786 int maxlen;
787 int ret;
788
789 ret = mesh_get_default_parameters(dev, &defs);
790
791 if (ret)
792 return ret;
793
794 if (defs.meshie.val.mesh_id_len > IEEE80211_MAX_SSID_LEN) {
795 lbs_pr_err("inconsistent mesh ID length");
796 defs.meshie.val.mesh_id_len = IEEE80211_MAX_SSID_LEN;
797 }
798
799 /* SSID not null terminated: reserve room for \0 + \n */
800 maxlen = defs.meshie.val.mesh_id_len + 2;
801 maxlen = (PAGE_SIZE > maxlen) ? maxlen : PAGE_SIZE;
802
803 defs.meshie.val.mesh_id[defs.meshie.val.mesh_id_len] = '\0';
804
805 return snprintf(buf, maxlen, "%s\n", defs.meshie.val.mesh_id);
806}
807
808/**
809 * @brief Set function for sysfs attribute mesh_id
810 */
811static ssize_t mesh_id_set(struct device *dev, struct device_attribute *attr,
812 const char *buf, size_t count)
813{
814 struct cmd_ds_mesh_config cmd;
815 struct mrvl_mesh_defaults defs;
816 struct mrvl_meshie *ie;
817 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
818 int len;
819 int ret;
820
821 if (count < 2 || count > IEEE80211_MAX_SSID_LEN + 1)
822 return -EINVAL;
823
824 memset(&cmd, 0, sizeof(struct cmd_ds_mesh_config));
825 ie = (struct mrvl_meshie *) &cmd.data[0];
826
827 /* fetch all other Information Element parameters */
828 ret = mesh_get_default_parameters(dev, &defs);
829
830 cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie));
831
832 /* transfer IE elements */
833 memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie));
834
835 len = count - 1;
836 memcpy(ie->val.mesh_id, buf, len);
837 /* SSID len */
838 ie->val.mesh_id_len = len;
839 /* IE len */
840 ie->len = sizeof(struct mrvl_meshie_val) - IEEE80211_MAX_SSID_LEN + len;
841
842 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
843 CMD_TYPE_MESH_SET_MESH_IE);
844 if (ret)
845 return ret;
846
847 return strlen(buf);
848}
849
850/**
851 * @brief Get function for sysfs attribute protocol_id
852 */
853static ssize_t protocol_id_get(struct device *dev,
854 struct device_attribute *attr, char *buf)
855{
856 struct mrvl_mesh_defaults defs;
857 int ret;
858
859 ret = mesh_get_default_parameters(dev, &defs);
860
861 if (ret)
862 return ret;
863
864 return snprintf(buf, 5, "%d\n", defs.meshie.val.active_protocol_id);
865}
866
867/**
868 * @brief Set function for sysfs attribute protocol_id
869 */
870static ssize_t protocol_id_set(struct device *dev,
871 struct device_attribute *attr, const char *buf, size_t count)
872{
873 struct cmd_ds_mesh_config cmd;
874 struct mrvl_mesh_defaults defs;
875 struct mrvl_meshie *ie;
876 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
877 uint32_t datum;
878 int ret;
879
880 memset(&cmd, 0, sizeof(cmd));
881 ret = sscanf(buf, "%d", &datum);
882 if ((ret != 1) || (datum > 255))
883 return -EINVAL;
884
885 /* fetch all other Information Element parameters */
886 ret = mesh_get_default_parameters(dev, &defs);
887
888 cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie));
889
890 /* transfer IE elements */
891 ie = (struct mrvl_meshie *) &cmd.data[0];
892 memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie));
893 /* update protocol id */
894 ie->val.active_protocol_id = datum;
895
896 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
897 CMD_TYPE_MESH_SET_MESH_IE);
898 if (ret)
899 return ret;
900
901 return strlen(buf);
902}
903
904/**
905 * @brief Get function for sysfs attribute metric_id
906 */
907static ssize_t metric_id_get(struct device *dev,
908 struct device_attribute *attr, char *buf)
909{
910 struct mrvl_mesh_defaults defs;
911 int ret;
912
913 ret = mesh_get_default_parameters(dev, &defs);
914
915 if (ret)
916 return ret;
917
918 return snprintf(buf, 5, "%d\n", defs.meshie.val.active_metric_id);
919}
920
921/**
922 * @brief Set function for sysfs attribute metric_id
923 */
924static ssize_t metric_id_set(struct device *dev, struct device_attribute *attr,
925 const char *buf, size_t count)
926{
927 struct cmd_ds_mesh_config cmd;
928 struct mrvl_mesh_defaults defs;
929 struct mrvl_meshie *ie;
930 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
931 uint32_t datum;
932 int ret;
933
934 memset(&cmd, 0, sizeof(cmd));
935 ret = sscanf(buf, "%d", &datum);
936 if ((ret != 1) || (datum > 255))
937 return -EINVAL;
938
939 /* fetch all other Information Element parameters */
940 ret = mesh_get_default_parameters(dev, &defs);
941
942 cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie));
943
944 /* transfer IE elements */
945 ie = (struct mrvl_meshie *) &cmd.data[0];
946 memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie));
947 /* update metric id */
948 ie->val.active_metric_id = datum;
949
950 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
951 CMD_TYPE_MESH_SET_MESH_IE);
952 if (ret)
953 return ret;
954
955 return strlen(buf);
956}
957
958/**
959 * @brief Get function for sysfs attribute capability
960 */
961static ssize_t capability_get(struct device *dev,
962 struct device_attribute *attr, char *buf)
963{
964 struct mrvl_mesh_defaults defs;
965 int ret;
966
967 ret = mesh_get_default_parameters(dev, &defs);
968
969 if (ret)
970 return ret;
971
972 return snprintf(buf, 5, "%d\n", defs.meshie.val.mesh_capability);
973}
974
975/**
976 * @brief Set function for sysfs attribute capability
977 */
978static ssize_t capability_set(struct device *dev, struct device_attribute *attr,
979 const char *buf, size_t count)
980{
981 struct cmd_ds_mesh_config cmd;
982 struct mrvl_mesh_defaults defs;
983 struct mrvl_meshie *ie;
984 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
985 uint32_t datum;
986 int ret;
987
988 memset(&cmd, 0, sizeof(cmd));
989 ret = sscanf(buf, "%d", &datum);
990 if ((ret != 1) || (datum > 255))
991 return -EINVAL;
992
993 /* fetch all other Information Element parameters */
994 ret = mesh_get_default_parameters(dev, &defs);
995
996 cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie));
997
998 /* transfer IE elements */
999 ie = (struct mrvl_meshie *) &cmd.data[0];
1000 memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie));
1001 /* update value */
1002 ie->val.mesh_capability = datum;
1003
1004 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
1005 CMD_TYPE_MESH_SET_MESH_IE);
1006 if (ret)
1007 return ret;
1008
1009 return strlen(buf);
1010}
1011
1012
1013static DEVICE_ATTR(bootflag, 0644, bootflag_get, bootflag_set);
1014static DEVICE_ATTR(boottime, 0644, boottime_get, boottime_set);
1015static DEVICE_ATTR(channel, 0644, channel_get, channel_set);
1016static DEVICE_ATTR(mesh_id, 0644, mesh_id_get, mesh_id_set);
1017static DEVICE_ATTR(protocol_id, 0644, protocol_id_get, protocol_id_set);
1018static DEVICE_ATTR(metric_id, 0644, metric_id_get, metric_id_set);
1019static DEVICE_ATTR(capability, 0644, capability_get, capability_set);
1020
1021static struct attribute *boot_opts_attrs[] = {
1022 &dev_attr_bootflag.attr,
1023 &dev_attr_boottime.attr,
1024 &dev_attr_channel.attr,
1025 NULL
1026};
1027
1028static struct attribute_group boot_opts_group = {
1029 .name = "boot_options",
1030 .attrs = boot_opts_attrs,
1031};
1032
1033static struct attribute *mesh_ie_attrs[] = {
1034 &dev_attr_mesh_id.attr,
1035 &dev_attr_protocol_id.attr,
1036 &dev_attr_metric_id.attr,
1037 &dev_attr_capability.attr,
1038 NULL
1039};
1040
1041static struct attribute_group mesh_ie_group = {
1042 .name = "mesh_ie",
1043 .attrs = mesh_ie_attrs,
1044};
1045
1046void lbs_persist_config_init(struct net_device *dev)
1047{
1048 int ret;
1049 ret = sysfs_create_group(&(dev->dev.kobj), &boot_opts_group);
1050 ret = sysfs_create_group(&(dev->dev.kobj), &mesh_ie_group);
1051}
1052
1053void lbs_persist_config_remove(struct net_device *dev)
1054{
1055 sysfs_remove_group(&(dev->dev.kobj), &boot_opts_group);
1056 sysfs_remove_group(&(dev->dev.kobj), &mesh_ie_group);
1057}
1058
1059
1060
1061/***************************************************************************
1062 * Ethtool related
1063 */
1064
1065static const char *mesh_stat_strings[] = {
1066 "drop_duplicate_bcast",
1067 "drop_ttl_zero",
1068 "drop_no_fwd_route",
1069 "drop_no_buffers",
1070 "fwded_unicast_cnt",
1071 "fwded_bcast_cnt",
1072 "drop_blind_table",
1073 "tx_failed_cnt"
1074};
1075
1076void lbs_mesh_ethtool_get_stats(struct net_device *dev,
1077 struct ethtool_stats *stats, uint64_t *data)
1078{
1079 struct lbs_private *priv = dev->ml_priv;
1080 struct cmd_ds_mesh_access mesh_access;
1081 int ret;
1082
1083 lbs_deb_enter(LBS_DEB_ETHTOOL);
1084
1085 /* Get Mesh Statistics */
1086 ret = lbs_mesh_access(priv, CMD_ACT_MESH_GET_STATS, &mesh_access);
1087
1088 if (ret) {
1089 memset(data, 0, MESH_STATS_NUM*(sizeof(uint64_t)));
1090 return;
1091 }
1092
1093 priv->mstats.fwd_drop_rbt = le32_to_cpu(mesh_access.data[0]);
1094 priv->mstats.fwd_drop_ttl = le32_to_cpu(mesh_access.data[1]);
1095 priv->mstats.fwd_drop_noroute = le32_to_cpu(mesh_access.data[2]);
1096 priv->mstats.fwd_drop_nobuf = le32_to_cpu(mesh_access.data[3]);
1097 priv->mstats.fwd_unicast_cnt = le32_to_cpu(mesh_access.data[4]);
1098 priv->mstats.fwd_bcast_cnt = le32_to_cpu(mesh_access.data[5]);
1099 priv->mstats.drop_blind = le32_to_cpu(mesh_access.data[6]);
1100 priv->mstats.tx_failed_cnt = le32_to_cpu(mesh_access.data[7]);
1101
1102 data[0] = priv->mstats.fwd_drop_rbt;
1103 data[1] = priv->mstats.fwd_drop_ttl;
1104 data[2] = priv->mstats.fwd_drop_noroute;
1105 data[3] = priv->mstats.fwd_drop_nobuf;
1106 data[4] = priv->mstats.fwd_unicast_cnt;
1107 data[5] = priv->mstats.fwd_bcast_cnt;
1108 data[6] = priv->mstats.drop_blind;
1109 data[7] = priv->mstats.tx_failed_cnt;
1110
1111 lbs_deb_enter(LBS_DEB_ETHTOOL);
1112}
1113
1114int lbs_mesh_ethtool_get_sset_count(struct net_device *dev, int sset)
1115{
1116 struct lbs_private *priv = dev->ml_priv;
1117
1118 if (sset == ETH_SS_STATS && dev == priv->mesh_dev)
1119 return MESH_STATS_NUM;
1120
1121 return -EOPNOTSUPP;
1122}
1123
1124void lbs_mesh_ethtool_get_strings(struct net_device *dev,
1125 uint32_t stringset, uint8_t *s)
1126{
1127 int i;
1128
1129 lbs_deb_enter(LBS_DEB_ETHTOOL);
1130
1131 switch (stringset) {
1132 case ETH_SS_STATS:
1133 for (i = 0; i < MESH_STATS_NUM; i++) {
1134 memcpy(s + i * ETH_GSTRING_LEN,
1135 mesh_stat_strings[i],
1136 ETH_GSTRING_LEN);
1137 }
1138 break;
1139 }
1140 lbs_deb_enter(LBS_DEB_ETHTOOL);
1141}
diff --git a/drivers/net/wireless/libertas/mesh.h b/drivers/net/wireless/libertas/mesh.h
new file mode 100644
index 000000000000..fea9b5d005fc
--- /dev/null
+++ b/drivers/net/wireless/libertas/mesh.h
@@ -0,0 +1,78 @@
1/**
2 * Contains all definitions needed for the Libertas' MESH implementation.
3 */
4#ifndef _LBS_MESH_H_
5#define _LBS_MESH_H_
6
7
8#include <net/iw_handler.h>
9#include <net/lib80211.h>
10
11
12/* Mesh statistics */
13struct lbs_mesh_stats {
14 u32 fwd_bcast_cnt; /* Fwd: Broadcast counter */
15 u32 fwd_unicast_cnt; /* Fwd: Unicast counter */
16 u32 fwd_drop_ttl; /* Fwd: TTL zero */
17 u32 fwd_drop_rbt; /* Fwd: Recently Broadcasted */
18 u32 fwd_drop_noroute; /* Fwd: No route to Destination */
19 u32 fwd_drop_nobuf; /* Fwd: Run out of internal buffers */
20 u32 drop_blind; /* Rx: Dropped by blinding table */
21 u32 tx_failed_cnt; /* Tx: Failed transmissions */
22};
23
24
25struct net_device;
26struct lbs_private;
27
28int lbs_init_mesh(struct lbs_private *priv);
29int lbs_deinit_mesh(struct lbs_private *priv);
30
31int lbs_add_mesh(struct lbs_private *priv);
32void lbs_remove_mesh(struct lbs_private *priv);
33
34
35/* Sending / Receiving */
36
37struct rxpd;
38struct txpd;
39
40struct net_device *lbs_mesh_set_dev(struct lbs_private *priv,
41 struct net_device *dev, struct rxpd *rxpd);
42void lbs_mesh_set_txpd(struct lbs_private *priv,
43 struct net_device *dev, struct txpd *txpd);
44
45
46/* Command handling */
47
48struct cmd_ds_command;
49
50int lbs_cmd_bt_access(struct cmd_ds_command *cmd,
51 u16 cmd_action, void *pdata_buf);
52int lbs_cmd_fwt_access(struct cmd_ds_command *cmd,
53 u16 cmd_action, void *pdata_buf);
54
55
56/* Persistent configuration */
57
58void lbs_persist_config_init(struct net_device *net);
59void lbs_persist_config_remove(struct net_device *net);
60
61
62/* WEXT handler */
63
64extern struct iw_handler_def mesh_handler_def;
65
66
67/* Ethtool statistics */
68
69struct ethtool_stats;
70
71void lbs_mesh_ethtool_get_stats(struct net_device *dev,
72 struct ethtool_stats *stats, uint64_t *data);
73int lbs_mesh_ethtool_get_sset_count(struct net_device *dev, int sset);
74void lbs_mesh_ethtool_get_strings(struct net_device *dev,
75 uint32_t stringset, uint8_t *s);
76
77
78#endif
diff --git a/drivers/net/wireless/libertas/persistcfg.c b/drivers/net/wireless/libertas/persistcfg.c
deleted file mode 100644
index 871f914a75fc..000000000000
--- a/drivers/net/wireless/libertas/persistcfg.c
+++ /dev/null
@@ -1,453 +0,0 @@
1#include <linux/moduleparam.h>
2#include <linux/delay.h>
3#include <linux/etherdevice.h>
4#include <linux/netdevice.h>
5#include <linux/if_arp.h>
6#include <linux/kthread.h>
7#include <linux/kfifo.h>
8
9#include "host.h"
10#include "decl.h"
11#include "dev.h"
12#include "wext.h"
13#include "debugfs.h"
14#include "scan.h"
15#include "assoc.h"
16#include "cmd.h"
17
18static int mesh_get_default_parameters(struct device *dev,
19 struct mrvl_mesh_defaults *defs)
20{
21 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
22 struct cmd_ds_mesh_config cmd;
23 int ret;
24
25 memset(&cmd, 0, sizeof(struct cmd_ds_mesh_config));
26 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_GET,
27 CMD_TYPE_MESH_GET_DEFAULTS);
28
29 if (ret)
30 return -EOPNOTSUPP;
31
32 memcpy(defs, &cmd.data[0], sizeof(struct mrvl_mesh_defaults));
33
34 return 0;
35}
36
37/**
38 * @brief Get function for sysfs attribute bootflag
39 */
40static ssize_t bootflag_get(struct device *dev,
41 struct device_attribute *attr, char *buf)
42{
43 struct mrvl_mesh_defaults defs;
44 int ret;
45
46 ret = mesh_get_default_parameters(dev, &defs);
47
48 if (ret)
49 return ret;
50
51 return snprintf(buf, 12, "%d\n", le32_to_cpu(defs.bootflag));
52}
53
54/**
55 * @brief Set function for sysfs attribute bootflag
56 */
57static ssize_t bootflag_set(struct device *dev, struct device_attribute *attr,
58 const char *buf, size_t count)
59{
60 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
61 struct cmd_ds_mesh_config cmd;
62 uint32_t datum;
63 int ret;
64
65 memset(&cmd, 0, sizeof(cmd));
66 ret = sscanf(buf, "%d", &datum);
67 if ((ret != 1) || (datum > 1))
68 return -EINVAL;
69
70 *((__le32 *)&cmd.data[0]) = cpu_to_le32(!!datum);
71 cmd.length = cpu_to_le16(sizeof(uint32_t));
72 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
73 CMD_TYPE_MESH_SET_BOOTFLAG);
74 if (ret)
75 return ret;
76
77 return strlen(buf);
78}
79
80/**
81 * @brief Get function for sysfs attribute boottime
82 */
83static ssize_t boottime_get(struct device *dev,
84 struct device_attribute *attr, char *buf)
85{
86 struct mrvl_mesh_defaults defs;
87 int ret;
88
89 ret = mesh_get_default_parameters(dev, &defs);
90
91 if (ret)
92 return ret;
93
94 return snprintf(buf, 12, "%d\n", defs.boottime);
95}
96
97/**
98 * @brief Set function for sysfs attribute boottime
99 */
100static ssize_t boottime_set(struct device *dev,
101 struct device_attribute *attr, const char *buf, size_t count)
102{
103 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
104 struct cmd_ds_mesh_config cmd;
105 uint32_t datum;
106 int ret;
107
108 memset(&cmd, 0, sizeof(cmd));
109 ret = sscanf(buf, "%d", &datum);
110 if ((ret != 1) || (datum > 255))
111 return -EINVAL;
112
113 /* A too small boot time will result in the device booting into
114 * standalone (no-host) mode before the host can take control of it,
115 * so the change will be hard to revert. This may be a desired
116 * feature (e.g to configure a very fast boot time for devices that
117 * will not be attached to a host), but dangerous. So I'm enforcing a
118 * lower limit of 20 seconds: remove and recompile the driver if this
119 * does not work for you.
120 */
121 datum = (datum < 20) ? 20 : datum;
122 cmd.data[0] = datum;
123 cmd.length = cpu_to_le16(sizeof(uint8_t));
124 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
125 CMD_TYPE_MESH_SET_BOOTTIME);
126 if (ret)
127 return ret;
128
129 return strlen(buf);
130}
131
132/**
133 * @brief Get function for sysfs attribute channel
134 */
135static ssize_t channel_get(struct device *dev,
136 struct device_attribute *attr, char *buf)
137{
138 struct mrvl_mesh_defaults defs;
139 int ret;
140
141 ret = mesh_get_default_parameters(dev, &defs);
142
143 if (ret)
144 return ret;
145
146 return snprintf(buf, 12, "%d\n", le16_to_cpu(defs.channel));
147}
148
149/**
150 * @brief Set function for sysfs attribute channel
151 */
152static ssize_t channel_set(struct device *dev, struct device_attribute *attr,
153 const char *buf, size_t count)
154{
155 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
156 struct cmd_ds_mesh_config cmd;
157 uint32_t datum;
158 int ret;
159
160 memset(&cmd, 0, sizeof(cmd));
161 ret = sscanf(buf, "%d", &datum);
162 if (ret != 1 || datum < 1 || datum > 11)
163 return -EINVAL;
164
165 *((__le16 *)&cmd.data[0]) = cpu_to_le16(datum);
166 cmd.length = cpu_to_le16(sizeof(uint16_t));
167 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
168 CMD_TYPE_MESH_SET_DEF_CHANNEL);
169 if (ret)
170 return ret;
171
172 return strlen(buf);
173}
174
175/**
176 * @brief Get function for sysfs attribute mesh_id
177 */
178static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr,
179 char *buf)
180{
181 struct mrvl_mesh_defaults defs;
182 int maxlen;
183 int ret;
184
185 ret = mesh_get_default_parameters(dev, &defs);
186
187 if (ret)
188 return ret;
189
190 if (defs.meshie.val.mesh_id_len > IEEE80211_MAX_SSID_LEN) {
191 lbs_pr_err("inconsistent mesh ID length");
192 defs.meshie.val.mesh_id_len = IEEE80211_MAX_SSID_LEN;
193 }
194
195 /* SSID not null terminated: reserve room for \0 + \n */
196 maxlen = defs.meshie.val.mesh_id_len + 2;
197 maxlen = (PAGE_SIZE > maxlen) ? maxlen : PAGE_SIZE;
198
199 defs.meshie.val.mesh_id[defs.meshie.val.mesh_id_len] = '\0';
200
201 return snprintf(buf, maxlen, "%s\n", defs.meshie.val.mesh_id);
202}
203
204/**
205 * @brief Set function for sysfs attribute mesh_id
206 */
207static ssize_t mesh_id_set(struct device *dev, struct device_attribute *attr,
208 const char *buf, size_t count)
209{
210 struct cmd_ds_mesh_config cmd;
211 struct mrvl_mesh_defaults defs;
212 struct mrvl_meshie *ie;
213 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
214 int len;
215 int ret;
216
217 if (count < 2 || count > IEEE80211_MAX_SSID_LEN + 1)
218 return -EINVAL;
219
220 memset(&cmd, 0, sizeof(struct cmd_ds_mesh_config));
221 ie = (struct mrvl_meshie *) &cmd.data[0];
222
223 /* fetch all other Information Element parameters */
224 ret = mesh_get_default_parameters(dev, &defs);
225
226 cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie));
227
228 /* transfer IE elements */
229 memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie));
230
231 len = count - 1;
232 memcpy(ie->val.mesh_id, buf, len);
233 /* SSID len */
234 ie->val.mesh_id_len = len;
235 /* IE len */
236 ie->len = sizeof(struct mrvl_meshie_val) - IEEE80211_MAX_SSID_LEN + len;
237
238 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
239 CMD_TYPE_MESH_SET_MESH_IE);
240 if (ret)
241 return ret;
242
243 return strlen(buf);
244}
245
246/**
247 * @brief Get function for sysfs attribute protocol_id
248 */
249static ssize_t protocol_id_get(struct device *dev,
250 struct device_attribute *attr, char *buf)
251{
252 struct mrvl_mesh_defaults defs;
253 int ret;
254
255 ret = mesh_get_default_parameters(dev, &defs);
256
257 if (ret)
258 return ret;
259
260 return snprintf(buf, 5, "%d\n", defs.meshie.val.active_protocol_id);
261}
262
263/**
264 * @brief Set function for sysfs attribute protocol_id
265 */
266static ssize_t protocol_id_set(struct device *dev,
267 struct device_attribute *attr, const char *buf, size_t count)
268{
269 struct cmd_ds_mesh_config cmd;
270 struct mrvl_mesh_defaults defs;
271 struct mrvl_meshie *ie;
272 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
273 uint32_t datum;
274 int ret;
275
276 memset(&cmd, 0, sizeof(cmd));
277 ret = sscanf(buf, "%d", &datum);
278 if ((ret != 1) || (datum > 255))
279 return -EINVAL;
280
281 /* fetch all other Information Element parameters */
282 ret = mesh_get_default_parameters(dev, &defs);
283
284 cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie));
285
286 /* transfer IE elements */
287 ie = (struct mrvl_meshie *) &cmd.data[0];
288 memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie));
289 /* update protocol id */
290 ie->val.active_protocol_id = datum;
291
292 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
293 CMD_TYPE_MESH_SET_MESH_IE);
294 if (ret)
295 return ret;
296
297 return strlen(buf);
298}
299
300/**
301 * @brief Get function for sysfs attribute metric_id
302 */
303static ssize_t metric_id_get(struct device *dev,
304 struct device_attribute *attr, char *buf)
305{
306 struct mrvl_mesh_defaults defs;
307 int ret;
308
309 ret = mesh_get_default_parameters(dev, &defs);
310
311 if (ret)
312 return ret;
313
314 return snprintf(buf, 5, "%d\n", defs.meshie.val.active_metric_id);
315}
316
317/**
318 * @brief Set function for sysfs attribute metric_id
319 */
320static ssize_t metric_id_set(struct device *dev, struct device_attribute *attr,
321 const char *buf, size_t count)
322{
323 struct cmd_ds_mesh_config cmd;
324 struct mrvl_mesh_defaults defs;
325 struct mrvl_meshie *ie;
326 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
327 uint32_t datum;
328 int ret;
329
330 memset(&cmd, 0, sizeof(cmd));
331 ret = sscanf(buf, "%d", &datum);
332 if ((ret != 1) || (datum > 255))
333 return -EINVAL;
334
335 /* fetch all other Information Element parameters */
336 ret = mesh_get_default_parameters(dev, &defs);
337
338 cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie));
339
340 /* transfer IE elements */
341 ie = (struct mrvl_meshie *) &cmd.data[0];
342 memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie));
343 /* update metric id */
344 ie->val.active_metric_id = datum;
345
346 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
347 CMD_TYPE_MESH_SET_MESH_IE);
348 if (ret)
349 return ret;
350
351 return strlen(buf);
352}
353
354/**
355 * @brief Get function for sysfs attribute capability
356 */
357static ssize_t capability_get(struct device *dev,
358 struct device_attribute *attr, char *buf)
359{
360 struct mrvl_mesh_defaults defs;
361 int ret;
362
363 ret = mesh_get_default_parameters(dev, &defs);
364
365 if (ret)
366 return ret;
367
368 return snprintf(buf, 5, "%d\n", defs.meshie.val.mesh_capability);
369}
370
371/**
372 * @brief Set function for sysfs attribute capability
373 */
374static ssize_t capability_set(struct device *dev, struct device_attribute *attr,
375 const char *buf, size_t count)
376{
377 struct cmd_ds_mesh_config cmd;
378 struct mrvl_mesh_defaults defs;
379 struct mrvl_meshie *ie;
380 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
381 uint32_t datum;
382 int ret;
383
384 memset(&cmd, 0, sizeof(cmd));
385 ret = sscanf(buf, "%d", &datum);
386 if ((ret != 1) || (datum > 255))
387 return -EINVAL;
388
389 /* fetch all other Information Element parameters */
390 ret = mesh_get_default_parameters(dev, &defs);
391
392 cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie));
393
394 /* transfer IE elements */
395 ie = (struct mrvl_meshie *) &cmd.data[0];
396 memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie));
397 /* update value */
398 ie->val.mesh_capability = datum;
399
400 ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET,
401 CMD_TYPE_MESH_SET_MESH_IE);
402 if (ret)
403 return ret;
404
405 return strlen(buf);
406}
407
408
409static DEVICE_ATTR(bootflag, 0644, bootflag_get, bootflag_set);
410static DEVICE_ATTR(boottime, 0644, boottime_get, boottime_set);
411static DEVICE_ATTR(channel, 0644, channel_get, channel_set);
412static DEVICE_ATTR(mesh_id, 0644, mesh_id_get, mesh_id_set);
413static DEVICE_ATTR(protocol_id, 0644, protocol_id_get, protocol_id_set);
414static DEVICE_ATTR(metric_id, 0644, metric_id_get, metric_id_set);
415static DEVICE_ATTR(capability, 0644, capability_get, capability_set);
416
417static struct attribute *boot_opts_attrs[] = {
418 &dev_attr_bootflag.attr,
419 &dev_attr_boottime.attr,
420 &dev_attr_channel.attr,
421 NULL
422};
423
424static struct attribute_group boot_opts_group = {
425 .name = "boot_options",
426 .attrs = boot_opts_attrs,
427};
428
429static struct attribute *mesh_ie_attrs[] = {
430 &dev_attr_mesh_id.attr,
431 &dev_attr_protocol_id.attr,
432 &dev_attr_metric_id.attr,
433 &dev_attr_capability.attr,
434 NULL
435};
436
437static struct attribute_group mesh_ie_group = {
438 .name = "mesh_ie",
439 .attrs = mesh_ie_attrs,
440};
441
442void lbs_persist_config_init(struct net_device *dev)
443{
444 int ret;
445 ret = sysfs_create_group(&(dev->dev.kobj), &boot_opts_group);
446 ret = sysfs_create_group(&(dev->dev.kobj), &mesh_ie_group);
447}
448
449void lbs_persist_config_remove(struct net_device *dev)
450{
451 sysfs_remove_group(&(dev->dev.kobj), &boot_opts_group);
452 sysfs_remove_group(&(dev->dev.kobj), &mesh_ie_group);
453}
diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c
index 9f18a19cc49d..2daf8ffdb7e1 100644
--- a/drivers/net/wireless/libertas/rx.c
+++ b/drivers/net/wireless/libertas/rx.c
@@ -160,15 +160,8 @@ int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb)
160 p_rx_pd = (struct rxpd *) skb->data; 160 p_rx_pd = (struct rxpd *) skb->data;
161 p_rx_pkt = (struct rxpackethdr *) ((u8 *)p_rx_pd + 161 p_rx_pkt = (struct rxpackethdr *) ((u8 *)p_rx_pd +
162 le32_to_cpu(p_rx_pd->pkt_ptr)); 162 le32_to_cpu(p_rx_pd->pkt_ptr));
163 if (priv->mesh_dev) { 163
164 if (priv->mesh_fw_ver == MESH_FW_OLD) { 164 dev = lbs_mesh_set_dev(priv, dev, p_rx_pd);
165 if (p_rx_pd->rx_control & RxPD_MESH_FRAME)
166 dev = priv->mesh_dev;
167 } else if (priv->mesh_fw_ver == MESH_FW_NEW) {
168 if (p_rx_pd->u.bss.bss_num == MESH_IFACE_ID)
169 dev = priv->mesh_dev;
170 }
171 }
172 165
173 lbs_deb_hex(LBS_DEB_RX, "RX Data: Before chop rxpd", skb->data, 166 lbs_deb_hex(LBS_DEB_RX, "RX Data: Before chop rxpd", skb->data,
174 min_t(unsigned int, skb->len, 100)); 167 min_t(unsigned int, skb->len, 100));
diff --git a/drivers/net/wireless/libertas/tx.c b/drivers/net/wireless/libertas/tx.c
index eb856adbf8ea..315d1ce286ca 100644
--- a/drivers/net/wireless/libertas/tx.c
+++ b/drivers/net/wireless/libertas/tx.c
@@ -131,12 +131,7 @@ netdev_tx_t lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
131 txpd->tx_packet_length = cpu_to_le16(pkt_len); 131 txpd->tx_packet_length = cpu_to_le16(pkt_len);
132 txpd->tx_packet_location = cpu_to_le32(sizeof(struct txpd)); 132 txpd->tx_packet_location = cpu_to_le32(sizeof(struct txpd));
133 133
134 if (dev == priv->mesh_dev) { 134 lbs_mesh_set_txpd(priv, dev, txpd);
135 if (priv->mesh_fw_ver == MESH_FW_OLD)
136 txpd->tx_control |= cpu_to_le32(TxPD_MESH_FRAME);
137 else if (priv->mesh_fw_ver == MESH_FW_NEW)
138 txpd->u.bss.bss_num = MESH_IFACE_ID;
139 }
140 135
141 lbs_deb_hex(LBS_DEB_TX, "txpd", (u8 *) &txpd, sizeof(struct txpd)); 136 lbs_deb_hex(LBS_DEB_TX, "txpd", (u8 *) &txpd, sizeof(struct txpd));
142 137
diff --git a/drivers/net/wireless/libertas/wext.h b/drivers/net/wireless/libertas/wext.h
index 7863baf7d234..f3f19fe8c6c6 100644
--- a/drivers/net/wireless/libertas/wext.h
+++ b/drivers/net/wireless/libertas/wext.h
@@ -7,12 +7,11 @@
7void lbs_send_disconnect_notification(struct lbs_private *priv); 7void lbs_send_disconnect_notification(struct lbs_private *priv);
8void lbs_send_mic_failureevent(struct lbs_private *priv, u32 event); 8void lbs_send_mic_failureevent(struct lbs_private *priv, u32 event);
9 9
10extern struct iw_handler_def lbs_handler_def;
11extern struct iw_handler_def mesh_handler_def;
12
13struct chan_freq_power *lbs_find_cfp_by_band_and_channel( 10struct chan_freq_power *lbs_find_cfp_by_band_and_channel(
14 struct lbs_private *priv, 11 struct lbs_private *priv,
15 u8 band, 12 u8 band,
16 u16 channel); 13 u16 channel);
17 14
15extern struct iw_handler_def lbs_handler_def;
16
18#endif 17#endif