2 * Copyright (c) 2010 Broadcom Corporation
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include <linux/kernel.h>
18 #include <linux/string.h>
19 #include <linux/netdevice.h>
20 #include <brcmu_wifi.h>
21 #include <brcmu_utils.h>
26 #include "fwil_types.h"
27 #include "tracepoint.h"
30 const u8 ALLFFMAC[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
32 #define BRCMF_DEFAULT_BCN_TIMEOUT 3
33 #define BRCMF_DEFAULT_SCAN_CHANNEL_TIME 40
34 #define BRCMF_DEFAULT_SCAN_UNASSOC_TIME 40
36 /* boost value for RSSI_DELTA in preferred join selection */
37 #define BRCMF_JOIN_PREF_RSSI_BOOST 8
39 int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
41 s8 eventmask[BRCMF_EVENTING_MASK_LEN];
42 u8 buf[BRCMF_DCMD_SMLEN];
43 struct brcmf_join_pref_params join_pref_params[2];
47 /* retreive mac address */
48 err = brcmf_fil_iovar_data_get(ifp, "cur_etheraddr", ifp->mac_addr,
49 sizeof(ifp->mac_addr));
51 brcmf_err("Retreiving cur_etheraddr failed, %d\n",
55 memcpy(ifp->drvr->mac, ifp->mac_addr, sizeof(ifp->drvr->mac));
57 /* query for 'ver' to get version info from firmware */
58 memset(buf, 0, sizeof(buf));
60 err = brcmf_fil_iovar_data_get(ifp, "ver", buf, sizeof(buf));
62 brcmf_err("Retreiving version information failed, %d\n",
69 /* Print fw version info */
70 brcmf_err("Firmware version = %s\n", buf);
72 /* locate firmware version number for ethtool */
73 ptr = strrchr(buf, ' ') + 1;
74 strlcpy(ifp->drvr->fwver, ptr, sizeof(ifp->drvr->fwver));
77 err = brcmf_fil_iovar_int_set(ifp, "mpc", 1);
79 brcmf_err("failed setting mpc\n");
84 * Setup timeout if Beacons are lost and roam is off to report
87 err = brcmf_fil_iovar_int_set(ifp, "bcn_timeout",
88 BRCMF_DEFAULT_BCN_TIMEOUT);
90 brcmf_err("bcn_timeout error (%d)\n", err);
94 /* Enable/Disable build-in roaming to allowed ext supplicant to take
97 err = brcmf_fil_iovar_int_set(ifp, "roam_off", 1);
99 brcmf_err("roam_off error (%d)\n", err);
103 /* Setup join_pref to select target by RSSI(with boost on 5GHz) */
104 join_pref_params[0].type = BRCMF_JOIN_PREF_RSSI_DELTA;
105 join_pref_params[0].len = 2;
106 join_pref_params[0].rssi_gain = BRCMF_JOIN_PREF_RSSI_BOOST;
107 join_pref_params[0].band = WLC_BAND_5G;
108 join_pref_params[1].type = BRCMF_JOIN_PREF_RSSI;
109 join_pref_params[1].len = 2;
110 join_pref_params[1].rssi_gain = 0;
111 join_pref_params[1].band = 0;
112 err = brcmf_fil_iovar_data_set(ifp, "join_pref", join_pref_params,
113 sizeof(join_pref_params));
115 brcmf_err("Set join_pref error (%d)\n", err);
117 /* Setup event_msgs, enable E_IF */
118 err = brcmf_fil_iovar_data_get(ifp, "event_msgs", eventmask,
119 BRCMF_EVENTING_MASK_LEN);
121 brcmf_err("Get event_msgs error (%d)\n", err);
124 setbit(eventmask, BRCMF_E_IF);
125 err = brcmf_fil_iovar_data_set(ifp, "event_msgs", eventmask,
126 BRCMF_EVENTING_MASK_LEN);
128 brcmf_err("Set event_msgs error (%d)\n", err);
132 /* Setup default scan channel time */
133 err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_CHANNEL_TIME,
134 BRCMF_DEFAULT_SCAN_CHANNEL_TIME);
136 brcmf_err("BRCMF_C_SET_SCAN_CHANNEL_TIME error (%d)\n",
141 /* Setup default scan unassoc time */
142 err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_UNASSOC_TIME,
143 BRCMF_DEFAULT_SCAN_UNASSOC_TIME);
145 brcmf_err("BRCMF_C_SET_SCAN_UNASSOC_TIME error (%d)\n",
150 /* do bus specific preinit here */
151 err = brcmf_bus_preinit(ifp->drvr->bus_if);
156 #if defined(CONFIG_BRCM_TRACING) || defined(CONFIG_BRCMDBG)
157 void __brcmf_dbg(u32 level, const char *func, const char *fmt, ...)
159 struct va_format vaf = {
166 if (brcmf_msg_level & level)
167 pr_debug("%s %pV", func, &vaf);
168 trace_brcmf_dbg(level, func, &vaf);