39 60, 90, 120, 180, 240, 360, 480, 540,
42 #define RTL818X_NR_B_RATES 4 43 #define RTL818X_NR_RATES 12 83 DBG2(
"rtl818x RX:%d CRC fail: flags %08x\n",
94 DBGP(
"rtl818x RX:%d success: flags %08x %08x\n",
161 #define DIV_ROUND_UP(n,d) (((n)+(d)-1)/(d)) 178 unsigned int remainder;
182 remainder = (16 * (
len + 4)) %
185 if (remainder > 0 && remainder <= 6)
189 entry = &
priv->tx_ring[
priv->tx_prod];
193 tx_flags |=
priv->hw_rtscts_rate << 19;
269 reg |= (1 << 15) | (1 << 14) | (1 << 4);
334 if (!
priv->rx_ring) {
335 DBG(
"rtl818x %s: cannot allocate RX ring\n", dev->
netdev->
name);
344 entry = &
priv->rx_ring[i];
348 priv->rx_buf[i] = iob;
379 if (!
priv->tx_ring) {
380 DBG(
"rtl818x %s: cannot allocate TX ring\n", dev->
netdev->
name);
564 priv->rf->conf_erp(dev);
611 unsigned int bit_id,
unsigned long data)
632 static const char *rtl818x_rf_names[] = {
635 "SA2400",
"max2820",
"GRF5101",
640 #define RTL818X_NR_RF_NAMES 11 658 const char *chip_name;
663 hwinfo =
zalloc(
sizeof(*hwinfo));
665 DBG(
"rtl818x: hwinfo alloc failed\n");
667 goto err_alloc_hwinfo;
674 DBG(
"rtl818x: net80211 alloc failed\n");
685 DBG(
"rtl818x: cannot find device memory\n");
706 DBG(
"rtl818x: Unknown chip! (0x%x)\n",
reg >> 25);
714 hwinfo->
flags = NET80211_HW_RX_HAS_FCS;
737 init_at93c66(&
priv->eeprom, 16);
739 init_at93c46(&
priv->eeprom, 16);
740 priv->eeprom.bus = &
priv->spibit.bus;
747 DBG2(
"rtl818x eeprom val = %04x\n", eeprom_val);
752 if (rf->
id == eeprom_val) {
760 if (eeprom_val < RTL818X_NR_RF_NAMES &&
761 rtl818x_rf_names[eeprom_val] !=
NULL)
762 DBG(
"rtl818x: %s RF frontend not supported!\n",
763 rtl818x_rf_names[eeprom_val]);
765 DBG(
"rtl818x: RF frontend #%d not recognized!\n",
774 priv->csthreshold = eeprom_val >> 8;
786 for (i = 0; i < 14; i += 2) {
788 nvs_read(&
priv->eeprom.nvs, 0x10 + (i >> 1), &txpwr, 2);
789 priv->txpower[i] = txpwr & 0xFF;
790 priv->txpower[i + 1] = txpwr >> 8;
795 for (i = 0; i < 14; i += 2) {
797 nvs_read(&
priv->eeprom.nvs, 0x20 + (i >> 1), &txpwr, 2);
798 priv->txpower[i] |= (txpwr & 0xFF) << 8;
799 priv->txpower[i + 1] |= txpwr & 0xFF00;
807 DBG(
"rtl818x: cannot register device\n");
813 DBG(
"rtl818x: Realtek RTL818%s (RF chip %s) with address %s\n",
static int rtl818x_init_tx_ring(struct net80211_device *dev)
#define RTL818X_RX_CONF_CSDM1
#define EINVAL
Invalid argument.
struct bit_basher basher
Bit-bashing interface.
#define RTL818X_CONFIG3_ANAPARAM_WRITE
struct arbelprm_rc_send_wqe rc
int modes
A bitwise OR of the 802.11x modes supported by this device.
void net80211_free(struct net80211_device *dev)
Free 802.11 device.
#define RTL818X_RX_CONF_RX_AUTORESETPHY
static int rtl818x_spi_read_bit(struct bit_basher *basher, unsigned int bit_id)
#define iob_put(iobuf, len)
static const u8 rtl818x_eeprom_bits[]
#define RTL818X_INT_RX_OK
#define RTL818X_MSR_INFRA
#define EBUSY
Device or resource busy.
static unsigned int unsigned int reg
static void rtl818x_handle_tx(struct net80211_device *dev)
void rtl818x_write_phy(struct net80211_device *dev, u8 addr, u32 data)
static u8 rtl818x_ioread8(struct rtl818x_priv *priv __unused, u8 *addr)
u8 channel
The channel currently in use, as an index into the channels array.
#define le32_to_cpu(value)
#define RTL818X_TX_CONF_R8185_D
#define RTL818X_TX_AGC_CTL_FEEDBACK_ANT
unsigned long ioaddr
I/O address.
#define RTL818X_TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT
static void rtl818x_iowrite8(struct rtl818x_priv *priv __unused, u8 *addr, u8 val)
#define RTL818X_EEPROM_CMD_CONFIG
void net80211_rx_err(struct net80211_device *dev, struct io_buffer *iob, int rc)
Indicate an error in receiving a packet.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
void net80211_rx(struct net80211_device *dev, struct io_buffer *iob, int signal, u16 rate)
Handle receipt of 802.11 frame.
u8 rtscts_rate
The rate to use for RTS/CTS transmissions.
#define RTL818X_RX_CONF_CSDM2
static void rtl818x_handle_rx(struct net80211_device *dev)
void net80211_unregister(struct net80211_device *dev)
Unregister 802.11 device from network stack.
#define RTL818X_CW_CONF_PERPACKET_RETRY_SHIFT
static const u16 rtl818x_rates[]
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
#define RTL818X_TX_CONF_R8185_ABC
static struct bit_basher_operations rtl818x_basher_ops
unsigned signal_max
Maximum signal in arbitrary cases.
#define RTL818X_TX_CONF_R8180_ABCD
enum net80211_hw_info::@630 signal_type
Signal strength information that can be provided by the device.
#define RTL818X_RF_DRIVERS
#define RTL818X_CMD_RESET
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
static const char * netdev_addr(struct net_device *netdev)
Get printable network device link-layer address.
struct device dev
Generic device.
#define RTL818X_CMD_TX_ENABLE
#define RTL818X_RX_CONF_BROADCAST
#define ECANCELED
Operation canceled.
int(* open)(struct net80211_device *dev)
Open 802.11 device.
struct net80211_device_operations rtl818x_operations
Dynamic memory allocation.
static void rtl818x_iowrite32(struct rtl818x_priv *priv __unused, u32 *addr, u32 val)
#define RTL818X_EEPROM_CMD_WRITE
#define NET80211_BAND_2GHZ
The 2.4 GHz ISM band, unlicensed in most countries.
u16 rates[NET80211_NR_BANDS][NET80211_MAX_RATES]
List of transmission rates supported by the card, indexed by band.
static void rtl818x_poll(struct net80211_device *dev)
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Operations that must be implemented by an 802.11 driver.
#define ENOMEM
Not enough space.
#define RTL818X_CW_CONF_PERPACKET_CW_SHIFT
#define RTL818X_NR_B_RATES
void * memcpy(void *dest, const void *src, size_t len) __nonnull
Three-wire serial interface.
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
static int rtl818x_tx(struct net80211_device *dev, struct io_buffer *iob)
Information on the capabilities of an 802.11 hardware device.
u8 hwaddr[ETH_ALEN]
Default hardware MAC address.
#define container_of(ptr, type, field)
Get containing structure.
#define RTL818X_TX_CONF_HW_SEQNUM
#define RTL818X_TX_CONF_SAT_HWPLCP
void init_spi_bit_basher(struct spi_bit_basher *spibit)
Initialise SPI bit-bashing interface.
int nr_rates[NET80211_NR_BANDS]
Number of supported rates, indexed by band.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
#define RTL818X_TX_CONF_R8180_F
uint16_t count
Number of entries.
static void rtl818x_spi_write_bit(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
#define RTL818X_EEPROM_CMD_PROGRAM
static void rtl818x_free_rx_ring(struct net80211_device *dev)
#define RTL818X_RX_CONF_NICMAC
#define cpu_to_le32(value)
void * priv
Driver private data.
static int rtl818x_init_rx_ring(struct net80211_device *dev)
#define RTL818X_INT_TXN_OK
int(* read)(struct bit_basher *basher, unsigned int bit_id)
Read input bit.
#define DIV_ROUND_UP(n, d)
#define NET80211_PHY_USE_PROTECTION
Whether to use RTS/CTS or CTS-to-self protection for transmissions.
struct net80211_device * net80211_alloc(size_t priv_size)
Allocate 802.11 device.
static void(* free)(struct refcnt *refcnt))
void * zalloc(size_t size)
Allocate cleared memory.
The iPXE 802.11 MAC layer.
static void rtl818x_stop(struct net80211_device *dev)
#define RTL818X_TX_CONF_HWVER_MASK
#define NET80211_CFG_PHY_PARAMS
Low-level link parameters (short preamble, protection, etc) have changed.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
#define NET80211_ASSOCIATED
Whether we have successfully associated with the network.
Structure encapsulating the complete state of an 802.11 device.
#define RTL818X_EEPROM_CMD_CK
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
#define RTL818X_EEPROM_CMD_CS
#define SPI_BIT_SS(slave)
Determine bit index for a particular slave.
#define RTL818X_TX_CONF_PROBE_DTS
static int rtl818x_start(struct net80211_device *dev)
struct spi_bit_basher spibit
#define NET80211_MODE_B
802.11b: 1-11 Mbps operation using DSSS/CCK signaling on the 2.4GHz band
void net80211_tx_complete(struct net80211_device *dev, struct io_buffer *iob, int retries, int rc)
Indicate the completed transmission of a packet.
#define le16_to_cpu(value)
u16 rates[NET80211_MAX_RATES]
A list of all possible TX rates we might use.
#define RTL818X_MAX_RETRIES
#define RTL818X_INT_RX_ERR
static int rtl818x_init_hw(struct net80211_device *dev)
int phy_flags
Physical layer options.
struct device * dev
Underlying hardware device.
#define RTL818X_RX_CONF_DATA
Network device management.
#define RTL818X_RX_CONF_ONLYERLPKT
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
struct net_device * netdev
The net_device that wraps us.
#define RTL818X_RX_RING_SIZE
static void rtl818x_irq(struct net80211_device *dev, int enable)
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
#define RF_PARAM_CARRIERSENSE1
#define RTL818X_INT_TXN_ERR
#define ENXIO
No such device or address.
char name[NETDEV_NAME_LEN]
Name of this network device.
static struct tlan_private * priv
#define RTL818X_EEPROM_CMD_NORMAL
#define NET80211_BAND_BIT_2GHZ
Bitmask for the 2GHz band.
#define RTL818X_TX_CONF_NO_ICV
static void rtl818x_free_tx_ring(struct net80211_device *dev)
void * data
Start of data.
#define EIO
Input/output error.
#define RTL818X_EEPROM_CMD_READ
#define RTL818X_CONFIG4_VCOOFF
struct net80211_channel channels[NET80211_MAX_CHANNELS]
A list of all possible channels we might use.
enum net80211_hw_info::@629 flags
A set of flags indicating peculiarities of this device.
void rtl818x_remove(struct pci_device *pdev)
static void rtl818x_set_hwaddr(struct net80211_device *dev, u8 *hwaddr)
#define cpu_to_le16(value)
#define RF_PARAM_CARRIERSENSE2
uint8_t data[48]
Additional event data.
#define RTL818X_RX_CONF_MGMT
#define ENOSYS
Function not implemented.
#define NET80211_CFG_RATE
Requested transmission rate (dev->rate) has changed.
static void rtl818x_iowrite16(struct rtl818x_priv *priv __unused, u16 *addr, u16 val)
int nvs_read(struct nvs_device *nvs, unsigned int address, void *data, size_t len)
Read from non-volatile storage device.
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
static u16 net80211_cts_duration(struct net80211_device *dev, int size)
Calculate duration field for a CTS control frame.
#define RTL818X_TX_RING_SIZE
#define NET80211_CFG_CHANNEL
Channel choice (dev->channel) or regulatory parameters have changed.
int bands
A bitwise OR of the bands on which this device can communicate.
u8 bssid[ETH_ALEN]
MAC address of the access point most recently associated.
#define SPI_MODE_THREEWIRE
Threewire-compatible mode.
#define RTL818X_CMD_RX_ENABLE
u16 state
State of our association to the network.
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
static int rtl818x_config(struct net80211_device *dev, int changed)
#define RTL818X_EEPROM_CMD_LOAD
static u16 rtl818x_ioread16(struct rtl818x_priv *priv __unused, u16 *addr)
#define DBG(...)
Print a debugging message.
void rtl818x_set_anaparam(struct rtl818x_priv *priv, u32 anaparam)
#define RTL818X_TX_AGC_CTL_PERPACKET_GAIN_SHIFT
#define RTL818X_MSR_NO_LINK
#define NULL
NULL pointer (VOID *)
unsigned channel_change_time
Estimate of the time required to change channels, in microseconds.
#define ETIMEDOUT
Connection timed out.
#define NET80211_CFG_ASSOC
Association has been established with a new BSS (dev->bssid)
u8 rate
The rate currently in use, as an index into the rates array.
struct bofm_section_header done
#define NET80211_MODE_G
802.11g: 54 Mbps operation using ERP/OFDM signaling on the 2.4GHz band
int rtl818x_probe(struct pci_device *pdev)
static u32 rtl818x_ioread32(struct rtl818x_priv *priv __unused, u32 *addr)
int net80211_register(struct net80211_device *dev, struct net80211_device_operations *ops, struct net80211_hw_info *hw)
Register 802.11 device with network stack.
if(natsemi->flags &NATSEMI_64BIT) return 1
#define RTL818X_RING_ALIGN
void * memset(void *dest, int character, size_t len) __nonnull