diff options
author | 2023-02-21 18:24:12 -0800 | |
---|---|---|
committer | 2023-02-21 18:24:12 -0800 | |
commit | 5b7c4cabbb65f5c469464da6c5f614cbd7f730f2 (patch) | |
tree | cc5c2d0a898769fd59549594fedb3ee6f84e59a0 /drivers/staging/vt6656/card.c | |
download | linux-5b7c4cabbb65f5c469464da6c5f614cbd7f730f2.tar.gz linux-5b7c4cabbb65f5c469464da6c5f614cbd7f730f2.zip |
Merge tag 'net-next-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-nextgrafted
Pull networking updates from Jakub Kicinski:
"Core:
- Add dedicated kmem_cache for typical/small skb->head, avoid having
to access struct page at kfree time, and improve memory use.
- Introduce sysctl to set default RPS configuration for new netdevs.
- Define Netlink protocol specification format which can be used to
describe messages used by each family and auto-generate parsers.
Add tools for generating kernel data structures and uAPI headers.
- Expose all net/core sysctls inside netns.
- Remove 4s sleep in netpoll if carrier is instantly detected on
boot.
- Add configurable limit of MDB entries per port, and port-vlan.
- Continue populating drop reasons throughout the stack.
- Retire a handful of legacy Qdiscs and classifiers.
Protocols:
- Support IPv4 big TCP (TSO frames larger than 64kB).
- Add IP_LOCAL_PORT_RANGE socket option, to control local port range
on socket by socket basis.
- Track and report in procfs number of MPTCP sockets used.
- Support mixing IPv4 and IPv6 flows in the in-kernel MPTCP path
manager.
- IPv6: don't check net.ipv6.route.max_size and rely on garbage
collection to free memory (similarly to IPv4).
- Support Penultimate Segment Pop (PSP) flavor in SRv6 (RFC8986).
- ICMP: add per-rate limit counters.
- Add support for user scanning requests in ieee802154.
- Remove static WEP support.
- Support minimal Wi-Fi 7 Extremely High Throughput (EHT) rate
reporting.
- WiFi 7 EHT channel puncturing support (client & AP).
BPF:
- Add a rbtree data structure following the "next-gen data structure"
precedent set by recently added linked list, that is, by using
kfunc + kptr instead of adding a new BPF map type.
- Expose XDP hints via kfuncs with initial support for RX hash and
timestamp metadata.
- Add BPF_F_NO_TUNNEL_KEY extension to bpf_skb_set_tunnel_key to
better support decap on GRE tunnel devices not operating in collect
metadata.
- Improve x86 JIT's codegen for PROBE_MEM runtime error checks.
- Remove the need for trace_printk_lock for bpf_trace_printk and
bpf_trace_vprintk helpers.
- Extend libbpf's bpf_tracing.h support for tracing arguments of
kprobes/uprobes and syscall as a special case.
- Significantly reduce the search time for module symbols by
livepatch and BPF.
- Enable cpumasks to be used as kptrs, which is useful for tracing
programs tracking which tasks end up running on which CPUs in
different time intervals.
- Add support for BPF trampoline on s390x and riscv64.
- Add capability to export the XDP features supported by the NIC.
- Add __bpf_kfunc tag for marking kernel functions as kfuncs.
- Add cgroup.memory=nobpf kernel parameter option to disable BPF
memory accounting for container environments.
Netfilter:
- Remove the CLUSTERIP target. It has been marked as obsolete for
years, and we still have WARN splats wrt races of the out-of-band
/proc interface installed by this target.
- Add 'destroy' commands to nf_tables. They are identical to the
existing 'delete' commands, but do not return an error if the
referenced object (set, chain, rule...) did not exist.
Driver API:
- Improve cpumask_local_spread() locality to help NICs set the right
IRQ affinity on AMD platforms.
- Separate C22 and C45 MDIO bus transactions more clearly.
- Introduce new DCB table to control DSCP rewrite on egress.
- Support configuration of Physical Layer Collision Avoidance (PLCA)
Reconciliation Sublayer (RS) (802.3cg-2019). Modern version of
shared medium Ethernet.
- Support for MAC Merge layer (IEEE 802.3-2018 clause 99). Allowing
preemption of low priority frames by high priority frames.
- Add support for controlling MACSec offload using netlink SET.
- Rework devlink instance refcounts to allow registration and
de-registration under the instance lock. Split the code into
multiple files, drop some of the unnecessarily granular locks and
factor out common parts of netlink operation handling.
- Add TX frame aggregation parameters (for USB drivers).
- Add a new attr TCA_EXT_WARN_MSG to report TC (offload) warning
messages with notifications for debug.
- Allow offloading of UDP NEW connections via act_ct.
- Add support for per action HW stats in TC.
- Support hardware miss to TC action (continue processing in SW from
a specific point in the action chain).
- Warn if old Wireless Extension user space interface is used with
modern cfg80211/mac80211 drivers. Do not support Wireless
Extensions for Wi-Fi 7 devices at all. Everyone should switch to
using nl80211 interface instead.
- Improve the CAN bit timing configuration. Use extack to return
error messages directly to user space, update the SJW handling,
including the definition of a new default value that will benefit
CAN-FD controllers, by increasing their oscillator tolerance.
New hardware / drivers:
- Ethernet:
- nVidia BlueField-3 support (control traffic driver)
- Ethernet support for imx93 SoCs
- Motorcomm yt8531 gigabit Ethernet PHY
- onsemi NCN26000 10BASE-T1S PHY (with support for PLCA)
- Microchip LAN8841 PHY (incl. cable diagnostics and PTP)
- Amlogic gxl MDIO mux
- WiFi:
- RealTek RTL8188EU (rtl8xxxu)
- Qualcomm Wi-Fi 7 devices (ath12k)
- CAN:
- Renesas R-Car V4H
Drivers:
- Bluetooth:
- Set Per Platform Antenna Gain (PPAG) for Intel controllers.
- Ethernet NICs:
- Intel (1G, igc):
- support TSN / Qbv / packet scheduling features of i226 model
- Intel (100G, ice):
- use GNSS subsystem instead of TTY
- multi-buffer XDP support
- extend support for GPIO pins to E823 devices
- nVidia/Mellanox:
- update the shared buffer configuration on PFC commands
- implement PTP adjphase function for HW offset control
- TC support for Geneve and GRE with VF tunnel offload
- more efficient crypto key management method
- multi-port eswitch support
- Netronome/Corigine:
- add DCB IEEE support
- support IPsec offloading for NFP3800
- Freescale/NXP (enetc):
- support XDP_REDIRECT for XDP non-linear buffers
- improve reconfig, avoid link flap and waiting for idle
- support MAC Merge layer
- Other NICs:
- sfc/ef100: add basic devlink support for ef100
- ionic: rx_push mode operation (writing descriptors via MMIO)
- bnxt: use the auxiliary bus abstraction for RDMA
- r8169: disable ASPM and reset bus in case of tx timeout
- cpsw: support QSGMII mode for J721e CPSW9G
- cpts: support pulse-per-second output
- ngbe: add an mdio bus driver
- usbnet: optimize usbnet_bh() by avoiding unnecessary queuing
- r8152: handle devices with FW with NCM support
- amd-xgbe: support 10Mbps, 2.5GbE speeds and rx-adaptation
- virtio-net: support multi buffer XDP
- virtio/vsock: replace virtio_vsock_pkt with sk_buff
- tsnep: XDP support
- Ethernet high-speed switches:
- nVidia/Mellanox (mlxsw):
- add support for latency TLV (in FW control messages)
- Microchip (sparx5):
- separate explicit and implicit traffic forwarding rules, make
the implicit rules always active
- add support for egress DSCP rewrite
- IS0 VCAP support (Ingress Classification)
- IS2 VCAP filters (protos, L3 addrs, L4 ports, flags, ToS
etc.)
- ES2 VCAP support (Egress Access Control)
- support for Per-Stream Filtering and Policing (802.1Q,
8.6.5.1)
- Ethernet embedded switches:
- Marvell (mv88e6xxx):
- add MAB (port auth) offload support
- enable PTP receive for mv88e6390
- NXP (ocelot):
- support MAC Merge layer
- support for the the vsc7512 internal copper phys
- Microchip:
- lan9303: convert to PHYLINK
- lan966x: support TC flower filter statistics
- lan937x: PTP support for KSZ9563/KSZ8563 and LAN937x
- lan937x: support Credit Based Shaper configuration
- ksz9477: support Energy Efficient Ethernet
- other:
- qca8k: convert to regmap read/write API, use bulk operations
- rswitch: Improve TX timestamp accuracy
- Intel WiFi (iwlwifi):
- EHT (Wi-Fi 7) rate reporting
- STEP equalizer support: transfer some STEP (connection to radio
on platforms with integrated wifi) related parameters from the
BIOS to the firmware.
- Qualcomm 802.11ax WiFi (ath11k):
- IPQ5018 support
- Fine Timing Measurement (FTM) responder role support
- channel 177 support
- MediaTek WiFi (mt76):
- per-PHY LED support
- mt7996: EHT (Wi-Fi 7) support
- Wireless Ethernet Dispatch (WED) reset support
- switch to using page pool allocator
- RealTek WiFi (rtw89):
- support new version of Bluetooth co-existance
- Mobile:
- rmnet: support TX aggregation"
* tag 'net-next-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next: (1872 commits)
page_pool: add a comment explaining the fragment counter usage
net: ethtool: fix __ethtool_dev_mm_supported() implementation
ethtool: pse-pd: Fix double word in comments
xsk: add linux/vmalloc.h to xsk.c
sefltests: netdevsim: wait for devlink instance after netns removal
selftest: fib_tests: Always cleanup before exit
net/mlx5e: Align IPsec ASO result memory to be as required by hardware
net/mlx5e: TC, Set CT miss to the specific ct action instance
net/mlx5e: Rename CHAIN_TO_REG to MAPPED_OBJ_TO_REG
net/mlx5: Refactor tc miss handling to a single function
net/mlx5: Kconfig: Make tc offload depend on tc skb extension
net/sched: flower: Support hardware miss to tc action
net/sched: flower: Move filter handle initialization earlier
net/sched: cls_api: Support hardware miss to tc action
net/sched: Rename user cookie and act cookie
sfc: fix builds without CONFIG_RTC_LIB
sfc: clean up some inconsistent indentings
net/mlx4_en: Introduce flexible array to silence overflow warning
net: lan966x: Fix possible deadlock inside PTP
net/ulp: Remove redundant ->clone() test in inet_clone_ulp().
...
Diffstat (limited to 'drivers/staging/vt6656/card.c')
-rw-r--r-- | drivers/staging/vt6656/card.c | 477 |
1 files changed, 477 insertions, 0 deletions
diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c new file mode 100644 index 000000000..7827e579e --- /dev/null +++ b/drivers/staging/vt6656/card.c @@ -0,0 +1,477 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. + * All rights reserved. + * + * Purpose: Provide functions to setup NIC operation mode + * Functions: + * vnt_set_rspinf - Set RSPINF + * vnt_update_ifs - Update slotTime,SIFS,DIFS, and EIFS + * vnt_update_top_rates - Update BasicTopRate + * vnt_add_basic_rate - Add to BasicRateSet + * vnt_ofdm_min_rate - Check if any OFDM rate is in BasicRateSet + * vnt_get_tsf_offset - Calculate TSFOffset + * vnt_get_current_tsf - Read Current NIC TSF counter + * vnt_get_next_tbtt - Calculate Next Beacon TSF counter + * vnt_reset_next_tbtt - Set NIC Beacon time + * vnt_update_next_tbtt - Sync. NIC Beacon time + * vnt_radio_power_off - Turn Off NIC Radio Power + * vnt_radio_power_on - Turn On NIC Radio Power + * + * Revision History: + * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec. + * 08-26-2003 Kyle Hsu: Modify the definition type of dwIoBase. + * 09-01-2003 Bryan YC Fan: Add vnt_update_ifs(). + * + */ + +#include <linux/bitops.h> +#include <linux/errno.h> +#include "device.h" +#include "card.h" +#include "baseband.h" +#include "mac.h" +#include "desc.h" +#include "rf.h" +#include "power.h" +#include "key.h" +#include "usbpipe.h" + +/* const u16 cw_rxbcntsf_off[MAX_RATE] = + * {17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3}; + */ + +static const u16 cw_rxbcntsf_off[MAX_RATE] = { + 192, 96, 34, 17, 34, 23, 17, 11, 8, 5, 4, 3 +}; + +int vnt_set_channel(struct vnt_private *priv, u32 connection_channel) +{ + int ret; + + if (connection_channel > CB_MAX_CHANNEL || !connection_channel) + return -EINVAL; + + /* clear NAV */ + vnt_mac_reg_bits_on(priv, MAC_REG_MACCR, MACCR_CLRNAV); + + /* Set Channel[7] = 0 to tell H/W channel is changing now. */ + vnt_mac_reg_bits_off(priv, MAC_REG_CHANNEL, + (BIT(7) | BIT(5) | BIT(4))); + + ret = vnt_control_out(priv, MESSAGE_TYPE_SELECT_CHANNEL, + connection_channel, 0, 0, NULL); + if (ret) + return ret; + + return vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, MAC_REG_CHANNEL, + (u8)(connection_channel | 0x80)); +} + +static const u8 vnt_rspinf_b_short_table[] = { + 0x70, 0x00, 0x00, 0x00, 0x38, 0x00, 0x09, 0x00, + 0x15, 0x00, 0x0a, 0x00, 0x0b, 0x00, 0x0b, 0x80 +}; + +static const u8 vnt_rspinf_b_long_table[] = { + 0x70, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, + 0x15, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x03, 0x80 +}; + +static const u8 vnt_rspinf_a_table[] = { + 0x9b, 0x18, 0x9f, 0x10, 0x9a, 0x0a, 0x9e, 0x08, 0x99, + 0x08, 0x9d, 0x04, 0x98, 0x04, 0x9c, 0x04, 0x9c, 0x04 +}; + +static const u8 vnt_rspinf_gb_table[] = { + 0x8b, 0x1e, 0x8f, 0x16, 0x8a, 0x12, 0x8e, 0x0e, 0x89, + 0x0e, 0x8d, 0x0a, 0x88, 0x0a, 0x8c, 0x0a, 0x8c, 0x0a +}; + +int vnt_set_rspinf(struct vnt_private *priv, u8 bb_type) +{ + const u8 *data; + u16 len; + int ret; + + if (priv->preamble_type) { + data = vnt_rspinf_b_short_table; + len = ARRAY_SIZE(vnt_rspinf_b_short_table); + } else { + data = vnt_rspinf_b_long_table; + len = ARRAY_SIZE(vnt_rspinf_b_long_table); + } + + /* RSPINF_b_1 to RSPINF_b_11 */ + ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_RSPINF_B_1, + MESSAGE_REQUEST_MACREG, len, data); + if (ret) + return ret; + + if (bb_type == BB_TYPE_11A) { + data = vnt_rspinf_a_table; + len = ARRAY_SIZE(vnt_rspinf_a_table); + } else { + data = vnt_rspinf_gb_table; + len = ARRAY_SIZE(vnt_rspinf_gb_table); + } + + /* RSPINF_a_6 to RSPINF_a_72 */ + return vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_RSPINF_A_6, + MESSAGE_REQUEST_MACREG, len, data); +} + +int vnt_update_ifs(struct vnt_private *priv) +{ + u8 max_min = 0; + u8 data[4]; + int ret; + + if (priv->packet_type == PK_TYPE_11A) { + priv->slot = C_SLOT_SHORT; + priv->sifs = C_SIFS_A; + priv->difs = C_SIFS_A + 2 * C_SLOT_SHORT; + max_min = 4; + } else { + priv->sifs = C_SIFS_BG; + + if (priv->short_slot_time) { + priv->slot = C_SLOT_SHORT; + max_min = 4; + } else { + priv->slot = C_SLOT_LONG; + max_min = 5; + } + + priv->difs = C_SIFS_BG + 2 * priv->slot; + } + + priv->eifs = C_EIFS; + + data[0] = (u8)priv->sifs; + data[1] = (u8)priv->difs; + data[2] = (u8)priv->eifs; + data[3] = (u8)priv->slot; + + ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_SIFS, + MESSAGE_REQUEST_MACREG, 4, &data[0]); + if (ret) + return ret; + + max_min |= 0xa0; + + return vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_CWMAXMIN0, + MESSAGE_REQUEST_MACREG, 1, &max_min); +} + +void vnt_update_top_rates(struct vnt_private *priv) +{ + int pos; + + pos = fls(priv->basic_rates & GENMASK(RATE_54M, RATE_6M)); + priv->top_ofdm_basic_rate = pos ? (pos - 1) : RATE_24M; + + pos = fls(priv->basic_rates & GENMASK(RATE_11M, RATE_1M)); + priv->top_cck_basic_rate = pos ? (pos - 1) : RATE_1M; +} + +bool vnt_ofdm_min_rate(struct vnt_private *priv) +{ + return priv->basic_rates & GENMASK(RATE_54M, RATE_6M) ? true : false; +} + +u8 vnt_get_pkt_type(struct vnt_private *priv) +{ + if (priv->bb_type == BB_TYPE_11A || priv->bb_type == BB_TYPE_11B) + return (u8)priv->bb_type; + else if (vnt_ofdm_min_rate(priv)) + return PK_TYPE_11GA; + return PK_TYPE_11GB; +} + +/* + * Description: Calculate TSF offset of two TSF input + * Get TSF Offset from RxBCN's TSF and local TSF + * + * Parameters: + * In: + * rx_rate - rx rate. + * tsf1 - Rx BCN's TSF + * tsf2 - Local TSF + * Out: + * none + * + * Return Value: TSF Offset value + * + */ +u64 vnt_get_tsf_offset(u8 rx_rate, u64 tsf1, u64 tsf2) +{ + return tsf1 - tsf2 - (u64)cw_rxbcntsf_off[rx_rate % MAX_RATE]; +} + +int vnt_adjust_tsf(struct vnt_private *priv, u8 rx_rate, + u64 time_stamp, u64 local_tsf) +{ + u64 tsf_offset = 0; + u8 data[8]; + + tsf_offset = vnt_get_tsf_offset(rx_rate, time_stamp, local_tsf); + + data[0] = (u8)tsf_offset; + data[1] = (u8)(tsf_offset >> 8); + data[2] = (u8)(tsf_offset >> 16); + data[3] = (u8)(tsf_offset >> 24); + data[4] = (u8)(tsf_offset >> 32); + data[5] = (u8)(tsf_offset >> 40); + data[6] = (u8)(tsf_offset >> 48); + data[7] = (u8)(tsf_offset >> 56); + + return vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT, + MESSAGE_REQUEST_TSF, 0, 8, data); +} + +/* + * Description: Read NIC TSF counter + * Get local TSF counter + * + * Parameters: + * In: + * priv - The adapter to be read + * Out: + * current_tsf - Current TSF counter + * + * Return Value: true if success; otherwise false + * + */ +bool vnt_get_current_tsf(struct vnt_private *priv, u64 *current_tsf) +{ + *current_tsf = priv->current_tsf; + + return true; +} + +/* + * Description: Clear NIC TSF counter + * Clear local TSF counter + * + * Parameters: + * In: + * priv - The adapter to be read + * + * Return Value: true if success; otherwise false + * + */ +bool vnt_clear_current_tsf(struct vnt_private *priv) +{ + vnt_mac_reg_bits_on(priv, MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); + + priv->current_tsf = 0; + + return true; +} + +/* + * Description: Read NIC TSF counter + * Get NEXTTBTT from adjusted TSF and Beacon Interval + * + * Parameters: + * In: + * tsf - Current TSF counter + * beacon_interval - Beacon Interval + * Out: + * tsf - Current TSF counter + * + * Return Value: TSF value of next Beacon + * + */ +u64 vnt_get_next_tbtt(u64 tsf, u16 beacon_interval) +{ + u32 beacon_int; + + beacon_int = beacon_interval * 1024; + + /* Next TBTT = + * ((local_current_TSF / beacon_interval) + 1) * beacon_interval + */ + if (beacon_int) { + do_div(tsf, beacon_int); + tsf += 1; + tsf *= beacon_int; + } + + return tsf; +} + +int vnt_reset_next_tbtt(struct vnt_private *priv, u16 beacon_interval) +{ + u64 next_tbtt = 0; + u8 data[8]; + + vnt_clear_current_tsf(priv); + + next_tbtt = vnt_get_next_tbtt(next_tbtt, beacon_interval); + + data[0] = (u8)next_tbtt; + data[1] = (u8)(next_tbtt >> 8); + data[2] = (u8)(next_tbtt >> 16); + data[3] = (u8)(next_tbtt >> 24); + data[4] = (u8)(next_tbtt >> 32); + data[5] = (u8)(next_tbtt >> 40); + data[6] = (u8)(next_tbtt >> 48); + data[7] = (u8)(next_tbtt >> 56); + + return vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT, + MESSAGE_REQUEST_TBTT, 0, 8, data); +} + +int vnt_update_next_tbtt(struct vnt_private *priv, u64 tsf, + u16 beacon_interval) +{ + u8 data[8]; + int ret; + + tsf = vnt_get_next_tbtt(tsf, beacon_interval); + + data[0] = (u8)tsf; + data[1] = (u8)(tsf >> 8); + data[2] = (u8)(tsf >> 16); + data[3] = (u8)(tsf >> 24); + data[4] = (u8)(tsf >> 32); + data[5] = (u8)(tsf >> 40); + data[6] = (u8)(tsf >> 48); + data[7] = (u8)(tsf >> 56); + + ret = vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT, + MESSAGE_REQUEST_TBTT, 0, 8, data); + if (ret) + return ret; + + dev_dbg(&priv->usb->dev, "%s TBTT: %8llx\n", __func__, tsf); + return 0; +} + +/* + * Description: Turn off Radio power + * + * Parameters: + * In: + * priv - The adapter to be turned off + * Out: + * none + * + * Return Value: true if success; otherwise false + * + */ +int vnt_radio_power_off(struct vnt_private *priv) +{ + int ret = 0; + + switch (priv->rf_type) { + case RF_AL2230: + case RF_AL2230S: + case RF_VT3226: + case RF_VT3226D0: + ret = vnt_mac_reg_bits_off(priv, MAC_REG_SOFTPWRCTL, + (SOFTPWRCTL_SWPE2 | + SOFTPWRCTL_SWPE3)); + break; + } + + if (ret) + goto end; + + ret = vnt_mac_reg_bits_off(priv, MAC_REG_HOSTCR, HOSTCR_RXON); + if (ret) + goto end; + + ret = vnt_set_deep_sleep(priv); + if (ret) + goto end; + + ret = vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL1, GPIO3_INTMD); + +end: + return ret; +} + +/* + * Description: Turn on Radio power + * + * Parameters: + * In: + * priv - The adapter to be turned on + * Out: + * none + * + * Return Value: true if success; otherwise false + * + */ +int vnt_radio_power_on(struct vnt_private *priv) +{ + int ret = 0; + + ret = vnt_exit_deep_sleep(priv); + if (ret) + return ret; + + ret = vnt_mac_reg_bits_on(priv, MAC_REG_HOSTCR, HOSTCR_RXON); + if (ret) + return ret; + + switch (priv->rf_type) { + case RF_AL2230: + case RF_AL2230S: + case RF_VT3226: + case RF_VT3226D0: + ret = vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL, + (SOFTPWRCTL_SWPE2 | + SOFTPWRCTL_SWPE3)); + if (ret) + return ret; + } + + return vnt_mac_reg_bits_off(priv, MAC_REG_GPIOCTL1, GPIO3_INTMD); +} + +int vnt_set_bss_mode(struct vnt_private *priv) +{ + int ret; + unsigned char type = priv->bb_type; + unsigned char data = 0; + unsigned char bb_vga_2_3 = 0x00; + + ret = vnt_mac_set_bb_type(priv, type); + if (ret) + return ret; + + priv->packet_type = vnt_get_pkt_type(priv); + + if (priv->bb_type == BB_TYPE_11A) { + data = 0x03; + bb_vga_2_3 = 0x10; + } else if (priv->bb_type == BB_TYPE_11B) { + data = 0x02; + } else if (priv->bb_type == BB_TYPE_11G) { + data = 0x08; + } + + if (data) { + ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, + 0x88, data); + if (ret) + return ret; + } + + ret = vnt_update_ifs(priv); + if (ret) + return ret; + + ret = vnt_set_rspinf(priv, priv->bb_type); + if (ret) + return ret; + + priv->bb_vga[2] = bb_vga_2_3; + priv->bb_vga[3] = bb_vga_2_3; + + return vnt_set_vga_gain_offset(priv, priv->bb_vga[0]); +} |