wlan_platform: Bring initial files for CNSS family drivers

Bring CNSS family drivers from msm-5.10 kernel as of commit
cc3bc4b888af (cnss2: Fix a few switch statement fallthrough
issues) to WLAN platform project. Fix SPDX-License format for
a few files as well.

drivers/net/wireless/cnss* -> .
include/net/cnss* -> inc/

Above shows how directories and header files are relocated.

Change-Id: If8fd40a35c9fdbeb1aa76a8aac5fdb1fc1c7e786
This commit is contained in:
Yue Ma
2021-10-06 18:50:15 -07:00
parent 40d31cc7a5
commit 5b29459b17
41 ha cambiato i file con 28664 aggiunte e 0 eliminazioni

278
inc/cnss2.h Normal file
Vedi File

@@ -0,0 +1,278 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */
#ifndef _NET_CNSS2_H
#define _NET_CNSS2_H
#include <linux/pci.h>
#define CNSS_MAX_FILE_NAME 20
#define CNSS_MAX_TIMESTAMP_LEN 32
#define CNSS_MAX_DEV_MEM_NUM 4
/*
* Temporary change for compilation, will be removed
* after WLAN host driver switched to use new APIs
*/
#define CNSS_API_WITH_DEV
enum cnss_bus_width_type {
CNSS_BUS_WIDTH_NONE,
CNSS_BUS_WIDTH_IDLE,
CNSS_BUS_WIDTH_LOW,
CNSS_BUS_WIDTH_MEDIUM,
CNSS_BUS_WIDTH_HIGH,
CNSS_BUS_WIDTH_VERY_HIGH,
CNSS_BUS_WIDTH_LOW_LATENCY
};
enum cnss_platform_cap_flag {
CNSS_HAS_EXTERNAL_SWREG = 0x01,
CNSS_HAS_UART_ACCESS = 0x02,
CNSS_HAS_DRV_SUPPORT = 0x04,
};
struct cnss_platform_cap {
u32 cap_flag;
};
struct cnss_fw_files {
char image_file[CNSS_MAX_FILE_NAME];
char board_data[CNSS_MAX_FILE_NAME];
char otp_data[CNSS_MAX_FILE_NAME];
char utf_file[CNSS_MAX_FILE_NAME];
char utf_board_data[CNSS_MAX_FILE_NAME];
char epping_file[CNSS_MAX_FILE_NAME];
char evicted_data[CNSS_MAX_FILE_NAME];
};
struct cnss_device_version {
u32 family_number;
u32 device_number;
u32 major_version;
u32 minor_version;
};
struct cnss_dev_mem_info {
u64 start;
u64 size;
};
struct cnss_soc_info {
void __iomem *va;
phys_addr_t pa;
uint32_t chip_id;
uint32_t chip_family;
uint32_t board_id;
uint32_t soc_id;
uint32_t fw_version;
char fw_build_timestamp[CNSS_MAX_TIMESTAMP_LEN + 1];
struct cnss_device_version device_version;
struct cnss_dev_mem_info dev_mem_info[CNSS_MAX_DEV_MEM_NUM];
};
struct cnss_wlan_runtime_ops {
int (*runtime_suspend)(struct pci_dev *pdev);
int (*runtime_resume)(struct pci_dev *pdev);
};
enum cnss_driver_status {
CNSS_UNINITIALIZED,
CNSS_INITIALIZED,
CNSS_LOAD_UNLOAD,
CNSS_RECOVERY,
CNSS_FW_DOWN,
CNSS_HANG_EVENT,
CNSS_BUS_EVENT,
};
enum cnss_bus_event_type {
BUS_EVENT_PCI_LINK_DOWN = 0,
BUS_EVENT_INVALID = 0xFFFF,
};
struct cnss_hang_event {
void *hang_event_data;
u16 hang_event_data_len;
};
struct cnss_bus_event {
enum cnss_bus_event_type etype;
void *event_data;
};
struct cnss_uevent_data {
enum cnss_driver_status status;
void *data;
};
struct cnss_wlan_driver {
char *name;
int (*probe)(struct pci_dev *pdev, const struct pci_device_id *id);
void (*remove)(struct pci_dev *pdev);
int (*idle_restart)(struct pci_dev *pdev,
const struct pci_device_id *id);
int (*idle_shutdown)(struct pci_dev *pdev);
int (*reinit)(struct pci_dev *pdev, const struct pci_device_id *id);
void (*shutdown)(struct pci_dev *pdev);
void (*crash_shutdown)(struct pci_dev *pdev);
int (*suspend)(struct pci_dev *pdev, pm_message_t state);
int (*resume)(struct pci_dev *pdev);
int (*suspend_noirq)(struct pci_dev *pdev);
int (*resume_noirq)(struct pci_dev *pdev);
void (*modem_status)(struct pci_dev *pdev, int state);
void (*update_status)(struct pci_dev *pdev, uint32_t status);
int (*update_event)(struct pci_dev *pdev,
struct cnss_uevent_data *uevent);
struct cnss_wlan_runtime_ops *runtime_ops;
const struct pci_device_id *id_table;
};
struct cnss_ce_tgt_pipe_cfg {
u32 pipe_num;
u32 pipe_dir;
u32 nentries;
u32 nbytes_max;
u32 flags;
u32 reserved;
};
struct cnss_ce_svc_pipe_cfg {
u32 service_id;
u32 pipe_dir;
u32 pipe_num;
};
struct cnss_shadow_reg_cfg {
u16 ce_id;
u16 reg_offset;
};
struct cnss_shadow_reg_v2_cfg {
u32 addr;
};
struct cnss_rri_over_ddr_cfg {
u32 base_addr_low;
u32 base_addr_high;
};
struct cnss_wlan_enable_cfg {
u32 num_ce_tgt_cfg;
struct cnss_ce_tgt_pipe_cfg *ce_tgt_cfg;
u32 num_ce_svc_pipe_cfg;
struct cnss_ce_svc_pipe_cfg *ce_svc_cfg;
u32 num_shadow_reg_cfg;
struct cnss_shadow_reg_cfg *shadow_reg_cfg;
u32 num_shadow_reg_v2_cfg;
struct cnss_shadow_reg_v2_cfg *shadow_reg_v2_cfg;
bool rri_over_ddr_cfg_valid;
struct cnss_rri_over_ddr_cfg rri_over_ddr_cfg;
};
enum cnss_driver_mode {
CNSS_MISSION,
CNSS_FTM,
CNSS_EPPING,
CNSS_WALTEST,
CNSS_OFF,
CNSS_CCPM,
CNSS_QVIT,
CNSS_CALIBRATION,
};
enum cnss_recovery_reason {
CNSS_REASON_DEFAULT,
CNSS_REASON_LINK_DOWN,
CNSS_REASON_RDDM,
CNSS_REASON_TIMEOUT,
};
enum cnss_remote_mem_type {
CNSS_REMOTE_MEM_TYPE_FW,
CNSS_REMOTE_MEM_TYPE_QDSS,
CNSS_REMOTE_MEM_TYPE_MAX,
};
struct cnss_mem_segment {
size_t size;
void *va;
phys_addr_t pa;
};
extern int cnss_wlan_register_driver(struct cnss_wlan_driver *driver);
extern void cnss_wlan_unregister_driver(struct cnss_wlan_driver *driver);
extern void cnss_device_crashed(struct device *dev);
extern int cnss_pci_prevent_l1(struct device *dev);
extern void cnss_pci_allow_l1(struct device *dev);
extern int cnss_pci_link_down(struct device *dev);
extern int cnss_pci_is_device_down(struct device *dev);
extern void cnss_schedule_recovery(struct device *dev,
enum cnss_recovery_reason reason);
extern int cnss_self_recovery(struct device *dev,
enum cnss_recovery_reason reason);
extern int cnss_force_fw_assert(struct device *dev);
extern int cnss_force_collect_rddm(struct device *dev);
extern int cnss_qmi_send_get(struct device *dev);
extern int cnss_qmi_send_put(struct device *dev);
extern int cnss_qmi_send(struct device *dev, int type, void *cmd,
int cmd_len, void *cb_ctx,
int (*cb)(void *ctx, void *event, int event_len));
extern void *cnss_get_virt_ramdump_mem(struct device *dev, unsigned long *size);
extern int cnss_get_fw_files_for_target(struct device *dev,
struct cnss_fw_files *pfw_files,
u32 target_type, u32 target_version);
extern int cnss_get_platform_cap(struct device *dev,
struct cnss_platform_cap *cap);
extern struct iommu_domain *cnss_smmu_get_domain(struct device *dev);
extern int cnss_smmu_map(struct device *dev,
phys_addr_t paddr, uint32_t *iova_addr, size_t size);
extern int cnss_smmu_unmap(struct device *dev, uint32_t iova_addr, size_t size);
extern int cnss_get_soc_info(struct device *dev, struct cnss_soc_info *info);
extern int cnss_request_bus_bandwidth(struct device *dev, int bandwidth);
extern int cnss_power_up(struct device *dev);
extern int cnss_power_down(struct device *dev);
extern int cnss_idle_restart(struct device *dev);
extern int cnss_idle_shutdown(struct device *dev);
extern void cnss_request_pm_qos(struct device *dev, u32 qos_val);
extern void cnss_remove_pm_qos(struct device *dev);
extern void cnss_lock_pm_sem(struct device *dev);
extern void cnss_release_pm_sem(struct device *dev);
extern void cnss_pci_lock_reg_window(struct device *dev, unsigned long *flags);
extern void cnss_pci_unlock_reg_window(struct device *dev,
unsigned long *flags);
extern int cnss_wlan_pm_control(struct device *dev, bool vote);
extern int cnss_auto_suspend(struct device *dev);
extern int cnss_auto_resume(struct device *dev);
extern int cnss_pci_is_drv_connected(struct device *dev);
extern int cnss_pci_force_wake_request_sync(struct device *dev, int timeout);
extern int cnss_pci_force_wake_request(struct device *dev);
extern int cnss_pci_is_device_awake(struct device *dev);
extern int cnss_pci_force_wake_release(struct device *dev);
extern int cnss_get_user_msi_assignment(struct device *dev, char *user_name,
int *num_vectors,
uint32_t *user_base_data,
uint32_t *base_vector);
extern int cnss_get_msi_irq(struct device *dev, unsigned int vector);
extern void cnss_get_msi_address(struct device *dev, uint32_t *msi_addr_low,
uint32_t *msi_addr_high);
extern int cnss_wlan_enable(struct device *dev,
struct cnss_wlan_enable_cfg *config,
enum cnss_driver_mode mode,
const char *host_version);
extern int cnss_wlan_disable(struct device *dev, enum cnss_driver_mode mode);
extern unsigned int cnss_get_boot_timeout(struct device *dev);
extern int cnss_athdiag_read(struct device *dev, uint32_t offset,
uint32_t mem_type, uint32_t data_len,
uint8_t *output);
extern int cnss_athdiag_write(struct device *dev, uint32_t offset,
uint32_t mem_type, uint32_t data_len,
uint8_t *input);
extern int cnss_set_fw_log_mode(struct device *dev, uint8_t fw_log_mode);
extern int cnss_set_pcie_gen_speed(struct device *dev, u8 pcie_gen_speed);
extern int cnss_get_mem_seg_count(enum cnss_remote_mem_type type, u32 *seg);
extern int cnss_get_mem_segment_info(enum cnss_remote_mem_type type,
struct cnss_mem_segment segment[],
u32 segment_count);
#endif /* _NET_CNSS2_H */

103
inc/cnss_nl.h Normal file
Vedi File

@@ -0,0 +1,103 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. */
#ifndef _NET_CNSS_GENETLINK_H_
#define _NET_CNSS_GENETLINK_H_
#include <linux/types.h>
#define CLD80211_MAX_COMMANDS 40
#define CLD80211_MAX_NL_DATA 4096
/**
* enum cld80211_attr - Driver/Application embeds the data in nlmsg with the
* help of below attributes
*
* @CLD80211_ATTR_VENDOR_DATA: Embed all other attributes in this nested
* attribute.
* @CLD80211_ATTR_DATA: Embed complete data in this attribute
* @CLD80211_ATTR_META_DATA: Embed meta data for above data. This will help
* wlan driver to peek into request message packet without opening up definition
* of complete request message.
* @CLD80211_ATTR_CMD: cld80211 vendor subcommand in this attribute
* @CLD80211_ATTR_CMD_TAG_DATA: cld80211 vendor subcommand data is present in
* this attribute. It is a nested attribute with sub attributes of specified
* vendor sub command.
*
* Any new message in future can be added as another attribute
*/
enum cld80211_attr {
CLD80211_ATTR_VENDOR_DATA = 1,
CLD80211_ATTR_DATA,
CLD80211_ATTR_META_DATA,
CLD80211_ATTR_CMD,
CLD80211_ATTR_CMD_TAG_DATA,
/* add new attributes above here */
__CLD80211_ATTR_AFTER_LAST,
CLD80211_ATTR_MAX = __CLD80211_ATTR_AFTER_LAST - 1
};
/**
* enum cld80211_multicast_groups - List of multicast groups supported
*
* @CLD80211_MCGRP_SVC_MSGS: WLAN service message will be sent to this group.
* Ex: Status ind messages
* @CLD80211_MCGRP_HOST_LOGS: All logging related messages from driver will be
* sent to this multicast group
* @CLD80211_MCGRP_FW_LOGS: Firmware logging messages will be sent to this group
* @CLD80211_MCGRP_PER_PKT_STATS: Messages related packet stats debugging infra
* will be sent to this group
* @CLD80211_MCGRP_DIAG_EVENTS: Driver/Firmware status logging diag events will
* be sent to this group
* @CLD80211_MCGRP_FATAL_EVENTS: Any fatal message generated in driver/firmware
* will be sent to this group
* @CLD80211_MCGRP_OEM_MSGS: All OEM message will be sent to this group
* Ex: LOWI messages
*/
enum cld80211_multicast_groups {
CLD80211_MCGRP_SVC_MSGS,
CLD80211_MCGRP_HOST_LOGS,
CLD80211_MCGRP_FW_LOGS,
CLD80211_MCGRP_PER_PKT_STATS,
CLD80211_MCGRP_DIAG_EVENTS,
CLD80211_MCGRP_FATAL_EVENTS,
CLD80211_MCGRP_OEM_MSGS,
};
/**
* typedef cld80211_cb - Callback to be called when an nlmsg is received with
* the registered cmd_id command from userspace
* @data: Payload of the message to be sent to driver
* @data_len: Length of the payload
* @cb_ctx: callback context to be returned to driver when the callback
* is called
* @pid: process id of the sender
*/
typedef void (*cld80211_cb)(const void *data, int data_len,
void *cb_ctx, int pid);
/**
* register_cld_cmd_cb() - Allows cld driver to register for commands with
* callback
* @cmd_id: Command to be registered. Valid range [1, CLD80211_MAX_COMMANDS]
* @cb: Callback to be called when an nlmsg is received with cmd_id command
* from userspace
* @cb_ctx: context provided by driver; Send this as cb_ctx of func()
* to driver
*/
int register_cld_cmd_cb(u8 cmd_id, cld80211_cb cb, void *cb_ctx);
/**
* deregister_cld_cmd_cb() - Allows cld driver to de-register the command it
* has already registered
* @cmd_id: Command to be deregistered.
*/
int deregister_cld_cmd_cb(u8 cmd_id);
/**
* cld80211_get_genl_family() - Returns current netlink family context
*/
struct genl_family *cld80211_get_genl_family(void);
#endif /* _NET_CNSS_GENETLINK_H_ */

16
inc/cnss_prealloc.h Normal file
Vedi File

@@ -0,0 +1,16 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2015-2016,2019 The Linux Foundation. All rights reserved. */
#ifndef _NET_CNSS_PREALLOC_H_
#define _NET_CNSS_PREALLOC_H_
#include <linux/types.h>
#define WCNSS_PRE_ALLOC_GET_THRESHOLD (4*1024)
extern void *wcnss_prealloc_get(size_t size);
extern int wcnss_prealloc_put(void *ptr);
extern int wcnss_pre_alloc_reset(void);
void wcnss_prealloc_check_memory_leak(void);
#endif /* _NET_CNSS__PREALLOC_H_ */

38
inc/cnss_utils.h Normal file
Vedi File

@@ -0,0 +1,38 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2017, 2019 The Linux Foundation. All rights reserved. */
#ifndef _CNSS_UTILS_H_
#define _CNSS_UTILS_H_
#include <linux/types.h>
struct device;
enum cnss_utils_cc_src {
CNSS_UTILS_SOURCE_CORE,
CNSS_UTILS_SOURCE_11D,
CNSS_UTILS_SOURCE_USER
};
extern int cnss_utils_set_wlan_unsafe_channel(struct device *dev,
u16 *unsafe_ch_list,
u16 ch_count);
extern int cnss_utils_get_wlan_unsafe_channel(struct device *dev,
u16 *unsafe_ch_list,
u16 *ch_count, u16 buf_len);
extern int cnss_utils_wlan_set_dfs_nol(struct device *dev,
const void *info, u16 info_len);
extern int cnss_utils_wlan_get_dfs_nol(struct device *dev,
void *info, u16 info_len);
extern int cnss_utils_get_driver_load_cnt(struct device *dev);
extern void cnss_utils_increment_driver_load_cnt(struct device *dev);
extern int cnss_utils_set_wlan_mac_address(const u8 *in, uint32_t len);
extern u8 *cnss_utils_get_wlan_mac_address(struct device *dev, uint32_t *num);
extern int cnss_utils_set_wlan_derived_mac_address(const u8 *in, uint32_t len);
extern u8 *cnss_utils_get_wlan_derived_mac_address(struct device *dev,
uint32_t *num);
extern void cnss_utils_set_cc_source(struct device *dev,
enum cnss_utils_cc_src cc_source);
extern enum cnss_utils_cc_src cnss_utils_get_cc_source(struct device *dev);
#endif