// Author: Xianjun Jiao, Michael Mehari, Wei Liu // SPDX-FileCopyrightText: 2019 UGent // SPDX-License-Identifier: AGPL-3.0-or-later #ifndef OPENWIFI_SDR #define OPENWIFI_SDR #include "pre_def.h" // -------------------for leds-------------------------------- struct gpio_led_data { //please always align with the leds-gpio.c in linux kernel struct led_classdev cdev; struct gpio_desc *gpiod; u8 can_sleep; u8 blinking; gpio_blink_set_t platform_gpio_blink_set; }; struct gpio_leds_priv { //please always align with the leds-gpio.c in linux kernel int num_leds; struct gpio_led_data leds[]; }; struct openwifi_rf_ops { char *name; // void (*init)(struct ieee80211_hw *); // void (*stop)(struct ieee80211_hw *); void (*set_chan)(struct ieee80211_hw *, struct ieee80211_conf *); // u8 (*calc_rssi)(u8 agc, u8 sq); }; struct openwifi_buffer_descriptor { // u32 num_dma_byte; // u32 sn; // u32 hw_queue_idx; // u32 retry_limit; // u32 need_ack; u8 prio; u16 len_mpdu; u16 seq_no; struct sk_buff *skb_linked; dma_addr_t dma_mapping_addr; // u32 reserved; } __packed; struct openwifi_ring { struct openwifi_buffer_descriptor *bds; u32 bd_wr_idx; u32 bd_rd_idx; int stop_flag; // -1: normal run; X>=0: stop due to queueX full // u32 num_dma_symbol_request; // u32 reserved; } __packed; struct openwifi_vif { struct ieee80211_hw *dev; int idx; // this vif's idx on the dev /* beaconing */ struct delayed_work beacon_work; bool enable_beacon; }; union u32_byte4 { u32 a; u8 c[4]; }; union u16_byte2 { u16 a; u8 c[2]; }; #define MAX_NUM_LED 4 #define OPENWIFI_LED_MAX_NAME_LEN 32 #define NUM_TX_ANT_MASK 3 #define NUM_RX_ANT_MASK 3 // -------------sdrctl reg category----------------- enum sdrctl_reg_cat { SDRCTL_REG_CAT_NO_USE = 0, SDRCTL_REG_CAT_RF, SDRCTL_REG_CAT_RX_INTF, SDRCTL_REG_CAT_TX_INTF, SDRCTL_REG_CAT_RX, SDRCTL_REG_CAT_TX, SDRCTL_REG_CAT_XPU, SDRCTL_REG_CAT_DRV_RX, SDRCTL_REG_CAT_DRV_TX, SDRCTL_REG_CAT_DRV_XPU, }; // ------------ software and RF reg definition ------------ #define MAX_NUM_DRV_REG 8 #define DRV_TX_REG_IDX_RATE 0 #define DRV_TX_REG_IDX_RATE_HT 1 #define DRV_TX_REG_IDX_RATE_VHT 2 #define DRV_TX_REG_IDX_RATE_HE 3 #define DRV_TX_REG_IDX_ANT_CFG 4 #define DRV_TX_REG_IDX_PRINT_CFG (MAX_NUM_DRV_REG-1) #define DRV_RX_REG_IDX_DEMOD_TH 0 #define DRV_RX_REG_IDX_ANT_CFG 4 #define DRV_RX_REG_IDX_PRINT_CFG (MAX_NUM_DRV_REG-1) #define DRV_XPU_REG_IDX_LBT_TH 0 #define DRV_XPU_REG_IDX_GIT_REV (MAX_NUM_DRV_REG-1) #define MAX_NUM_RF_REG 8 #define RF_TX_REG_IDX_ATT 0 #define RF_TX_REG_IDX_FREQ_MHZ 1 #define RF_RX_REG_IDX_GAIN 4 #define RF_RX_REG_IDX_FREQ_MHZ 5 // ------end of software and RF reg definition ------------ // -------------dmesg printk control flag------------------ #define DMESG_LOG_ERROR (1<<0) #define DMESG_LOG_UNICAST (1<<1) #define DMESG_LOG_BROADCAST (1<<2) #define DMESG_LOG_NORMAL_QUEUE_STOP (1<<3) #define DMESG_LOG_ANY (0xF) // ------end of dmesg printk control flag------------------ #define MAX_NUM_VIF 4 //#define LEN_PHY_HEADER 16 #define LEN_PHY_CRC 4 #define LEN_MPDU_DELIM 4 #define MAX_NUM_HW_QUEUE 4 // number of queue in FPGA #define MAX_NUM_SW_QUEUE 4 // number of queue in Linux, depends on the number we report by dev->queues in openwifi_dev_probe #define RING_ROOM_THRESHOLD (2+MAX_NUM_SW_QUEUE) // MAX_NUM_SW_QUEUE is for the room of MAX_NUM_SW_QUEUE last packets from MAX_NUM_SW_QUEUE queue before stop #define NUM_BIT_NUM_TX_BD 6 #define NUM_TX_BD (1<