if_malo.c (178957) | if_malo.c (190526) |
---|---|
1/*- 2 * Copyright (c) 2008 Weongyo Jeong <weongyo@freebsd.org> 3 * Copyright (c) 2007 Marvell Semiconductor, Inc. 4 * Copyright (c) 2007 Sam Leffler, Errno Consulting 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 17 unchanged lines hidden (view full) --- 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 27 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 29 * THE POSSIBILITY OF SUCH DAMAGES. 30 */ 31 32#include <sys/cdefs.h> 33#ifdef __FreeBSD__ | 1/*- 2 * Copyright (c) 2008 Weongyo Jeong <weongyo@freebsd.org> 3 * Copyright (c) 2007 Marvell Semiconductor, Inc. 4 * Copyright (c) 2007 Sam Leffler, Errno Consulting 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 17 unchanged lines hidden (view full) --- 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 27 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 29 * THE POSSIBILITY OF SUCH DAMAGES. 30 */ 31 32#include <sys/cdefs.h> 33#ifdef __FreeBSD__ |
34__FBSDID("$FreeBSD: head/sys/dev/malo/if_malo.c 178957 2008-05-12 00:15:30Z sam $"); | 34__FBSDID("$FreeBSD: head/sys/dev/malo/if_malo.c 190526 2009-03-29 17:59:14Z sam $"); |
35#endif 36 37#include "opt_malo.h" 38 39#include <sys/param.h> 40#include <sys/endian.h> 41#include <sys/kernel.h> 42#include <sys/socket.h> --- 127 unchanged lines hidden (view full) --- 170malo_bar0_write4(struct malo_softc *sc, bus_size_t off, uint32_t val) 171{ 172 DPRINTF(sc, MALO_DEBUG_FW, "%s: off 0x%zx val 0x%x\n", 173 __func__, off, val); 174 175 bus_space_write_4(sc->malo_io0t, sc->malo_io0h, off, val); 176} 177 | 35#endif 36 37#include "opt_malo.h" 38 39#include <sys/param.h> 40#include <sys/endian.h> 41#include <sys/kernel.h> 42#include <sys/socket.h> --- 127 unchanged lines hidden (view full) --- 170malo_bar0_write4(struct malo_softc *sc, bus_size_t off, uint32_t val) 171{ 172 DPRINTF(sc, MALO_DEBUG_FW, "%s: off 0x%zx val 0x%x\n", 173 __func__, off, val); 174 175 bus_space_write_4(sc->malo_io0t, sc->malo_io0h, off, val); 176} 177 |
178static uint8_t 179malo_bar1_read1(struct malo_softc *sc, bus_size_t off) 180{ 181 return bus_space_read_1(sc->malo_io1t, sc->malo_io1h, off); 182} 183 | |
184int 185malo_attach(uint16_t devid, struct malo_softc *sc) 186{ | 178int 179malo_attach(uint16_t devid, struct malo_softc *sc) 180{ |
187 int error, i; | 181 int error; |
188 struct ieee80211com *ic; 189 struct ifnet *ifp; 190 struct malo_hal *mh; 191 uint8_t bands; 192 193 ifp = sc->malo_ifp = if_alloc(IFT_IEEE80211); 194 if (ifp == NULL) { 195 device_printf(sc->malo_dev, "can not if_alloc()\n"); 196 return ENOSPC; 197 } 198 ic = ifp->if_l2com; 199 200 MALO_LOCK_INIT(sc); 201 202 /* set these up early for if_printf use */ 203 if_initname(ifp, device_get_name(sc->malo_dev), 204 device_get_unit(sc->malo_dev)); 205 | 182 struct ieee80211com *ic; 183 struct ifnet *ifp; 184 struct malo_hal *mh; 185 uint8_t bands; 186 187 ifp = sc->malo_ifp = if_alloc(IFT_IEEE80211); 188 if (ifp == NULL) { 189 device_printf(sc->malo_dev, "can not if_alloc()\n"); 190 return ENOSPC; 191 } 192 ic = ifp->if_l2com; 193 194 MALO_LOCK_INIT(sc); 195 196 /* set these up early for if_printf use */ 197 if_initname(ifp, device_get_name(sc->malo_dev), 198 device_get_unit(sc->malo_dev)); 199 |
206 /* 207 * NB: get mac address from hardware directly here before we set DMAs 208 * for HAL because we don't want to disturb operations of HAL at BAR 1. 209 */ 210 for (i = 0; i < IEEE80211_ADDR_LEN; i++) { 211 /* XXX remove a magic number but we don't have documents. */ 212 ic->ic_myaddr[i] = malo_bar1_read1(sc, 0xa528 + i); 213 DELAY(1000); 214 } 215 | |
216 mh = malo_hal_attach(sc->malo_dev, devid, 217 sc->malo_io1h, sc->malo_io1t, sc->malo_dmat); 218 if (mh == NULL) { 219 if_printf(ifp, "unable to attach HAL\n"); 220 error = EIO; 221 goto bad; 222 } 223 sc->malo_mh = mh; --- 90 unchanged lines hidden (view full) --- 314 * Transmit requires space in the packet for a special format transmit 315 * record and optional padding between this record and the payload. 316 * Ask the net80211 layer to arrange this when encapsulating 317 * packets so we can add it efficiently. 318 */ 319 ic->ic_headroom = sizeof(struct malo_txrec) - 320 sizeof(struct ieee80211_frame); 321 | 200 mh = malo_hal_attach(sc->malo_dev, devid, 201 sc->malo_io1h, sc->malo_io1t, sc->malo_dmat); 202 if (mh == NULL) { 203 if_printf(ifp, "unable to attach HAL\n"); 204 error = EIO; 205 goto bad; 206 } 207 sc->malo_mh = mh; --- 90 unchanged lines hidden (view full) --- 298 * Transmit requires space in the packet for a special format transmit 299 * record and optional padding between this record and the payload. 300 * Ask the net80211 layer to arrange this when encapsulating 301 * packets so we can add it efficiently. 302 */ 303 ic->ic_headroom = sizeof(struct malo_txrec) - 304 sizeof(struct ieee80211_frame); 305 |
322 /* get mac address from hardware */ 323 IEEE80211_ADDR_COPY(ic->ic_myaddr, sc->malo_hwspecs.macaddr); 324 | |
325 /* call MI attach routine. */ | 306 /* call MI attach routine. */ |
326 ieee80211_ifattach(ic); | 307 ieee80211_ifattach(ic, sc->malo_hwspecs.macaddr); |
327 /* override default methods */ 328 ic->ic_vap_create = malo_vap_create; 329 ic->ic_vap_delete = malo_vap_delete; 330 ic->ic_raw_xmit = malo_raw_xmit; 331 ic->ic_updateslot = malo_updateslot; 332 333 ic->ic_scan_start = malo_scan_start; 334 ic->ic_scan_end = malo_scan_end; --- 1296 unchanged lines hidden (view full) --- 1631static int 1632malo_mode_init(struct malo_softc *sc) 1633{ 1634 struct ifnet *ifp = sc->malo_ifp; 1635 struct ieee80211com *ic = ifp->if_l2com; 1636 struct malo_hal *mh = sc->malo_mh; 1637 1638 /* | 308 /* override default methods */ 309 ic->ic_vap_create = malo_vap_create; 310 ic->ic_vap_delete = malo_vap_delete; 311 ic->ic_raw_xmit = malo_raw_xmit; 312 ic->ic_updateslot = malo_updateslot; 313 314 ic->ic_scan_start = malo_scan_start; 315 ic->ic_scan_end = malo_scan_end; --- 1296 unchanged lines hidden (view full) --- 1612static int 1613malo_mode_init(struct malo_softc *sc) 1614{ 1615 struct ifnet *ifp = sc->malo_ifp; 1616 struct ieee80211com *ic = ifp->if_l2com; 1617 struct malo_hal *mh = sc->malo_mh; 1618 1619 /* |
1639 * Handle any link-level address change. Note that we only 1640 * need to force ic_myaddr; any other addresses are handled 1641 * as a byproduct of the ifnet code marking the interface 1642 * down then up. 1643 */ 1644 IEEE80211_ADDR_COPY(ic->ic_myaddr, IF_LLADDR(ifp)); 1645 1646 /* | |
1647 * NB: Ignore promisc in hostap mode; it's set by the 1648 * bridge. This is wrong but we have no way to 1649 * identify internal requests (from the bridge) 1650 * versus external requests such as for tcpdump. 1651 */ 1652 malo_hal_setpromisc(mh, (ifp->if_flags & IFF_PROMISC) && 1653 ic->ic_opmode != IEEE80211_M_HOSTAP); 1654 malo_setmcastfilter(sc); --- 690 unchanged lines hidden --- | 1620 * NB: Ignore promisc in hostap mode; it's set by the 1621 * bridge. This is wrong but we have no way to 1622 * identify internal requests (from the bridge) 1623 * versus external requests such as for tcpdump. 1624 */ 1625 malo_hal_setpromisc(mh, (ifp->if_flags & IFF_PROMISC) && 1626 ic->ic_opmode != IEEE80211_M_HOSTAP); 1627 malo_setmcastfilter(sc); --- 690 unchanged lines hidden --- |