source: rtems-libbsd/freebsd/sys/dev/rtwn/rtl8812a/r12a_caps.c @ 0cbb715

55-freebsd-126-freebsd-12
Last change on this file since 0cbb715 was 0cbb715, checked in by Christian Mauderer <Christian.Mauderer@…>, on 11/22/16 at 09:41:47

rtwn: Import from FreeBSD.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1#include <machine/rtems-bsd-kernel-space.h>
2
3/*-
4 * Copyright (c) 2016 Andriy Voskoboinyk <avos@FreeBSD.org>
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
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD$");
31
32#include <rtems/bsd/local/opt_wlan.h>
33
34#include <rtems/bsd/sys/param.h>
35#include <sys/sockio.h>
36#include <rtems/bsd/sys/lock.h>
37#include <sys/mutex.h>
38#include <sys/mbuf.h>
39#include <sys/kernel.h>
40#include <sys/socket.h>
41#include <sys/systm.h>
42#include <sys/malloc.h>
43#include <sys/queue.h>
44#include <sys/taskqueue.h>
45#include <sys/bus.h>
46#include <sys/endian.h>
47#include <sys/linker.h>
48
49#include <net/if.h>
50#include <net/if_var.h>
51#include <net/ethernet.h>
52#include <net/if_media.h>
53
54#include <net80211/ieee80211_var.h>
55#include <net80211/ieee80211_radiotap.h>
56
57#include <dev/rtwn/if_rtwnvar.h>
58#include <dev/rtwn/if_rtwn_rx.h>
59
60#include <dev/rtwn/rtl8812a/r12a.h>
61#include <dev/rtwn/rtl8812a/r12a_reg.h>
62#include <dev/rtwn/rtl8812a/r12a_var.h>
63
64
65int
66r12a_ioctl_net(struct ieee80211com *ic, u_long cmd, void *data)
67{
68        struct rtwn_softc *sc = ic->ic_softc;
69        struct r12a_softc *rs = sc->sc_priv;
70        struct ifreq *ifr = (struct ifreq *)data;
71        int error;
72
73        error = 0;
74        switch (cmd) {
75        case SIOCSIFCAP:
76        {
77                struct ieee80211vap *vap;
78                int changed, rxmask;
79
80                rxmask = ifr->ifr_reqcap & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6);
81
82                RTWN_LOCK(sc);
83                changed = 0;
84                if (!(rs->rs_flags & R12A_RXCKSUM_EN) ^
85                    !(ifr->ifr_reqcap & IFCAP_RXCSUM)) {
86                        rs->rs_flags ^= R12A_RXCKSUM_EN;
87                        changed = 1;
88                }
89                if (!(rs->rs_flags & R12A_RXCKSUM6_EN) ^
90                    !(ifr->ifr_reqcap & IFCAP_RXCSUM_IPV6)) {
91                        rs->rs_flags ^= R12A_RXCKSUM6_EN;
92                        changed = 1;
93                }
94                if (changed) {
95                        if (rxmask == 0)
96                                sc->rcr &= ~R12A_RCR_TCP_OFFLD_EN;
97                        else
98                                sc->rcr |= R12A_RCR_TCP_OFFLD_EN;
99
100                        if (sc->sc_flags & RTWN_RUNNING)
101                                rtwn_rxfilter_set(sc);
102                }
103                RTWN_UNLOCK(sc);
104
105                IEEE80211_LOCK(ic);     /* XXX */
106                TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
107                        struct ifnet *ifp = vap->iv_ifp;
108
109                        ifp->if_capenable &=
110                            ~(IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6);
111                        ifp->if_capenable |= rxmask;
112                }
113                IEEE80211_UNLOCK(ic);
114                break;
115        }
116        default:
117                error = ENOTTY;         /* for net80211 */
118                break;
119        }
120
121        return (error);
122}
Note: See TracBrowser for help on using the repository browser.