HelenOS sources
#ifndef ATHEROS_HTC_H
#define ATHEROS_HTC_H
#include <ieee80211.h>
#include <fibril_synch.h>
#include <usb/dev/driver.h>
#include <stddef.h>
#include <stdint.h>
#include <nic.h>
#include "ath.h"
#define HTC_RTS_THRESHOLD 2304
#define HTC_RATES_MAX_LENGTH 30
typedef enum {
HTC_MESSAGE_READY = 1,
HTC_MESSAGE_CONNECT_SERVICE,
HTC_MESSAGE_CONNECT_SERVICE_RESPONSE,
HTC_MESSAGE_SETUP_COMPLETE,
HTC_MESSAGE_CONFIG
} htc_message_id_t;
typedef enum {
HTC_SERVICE_SUCCESS = 0,
HTC_SERVICE_NOT_FOUND,
HTC_SERVICE_FAILED,
HTC_SERVICE_NO_RESOURCES,
HTC_SERVICE_NO_MORE_EP
} htc_response_status_code_t;
typedef enum {
HTC_OPMODE_ADHOC = 0,
HTC_OPMODE_STATION = 1,
HTC_OPMODE_MESH = 2,
HTC_OPMODE_AP = 6
} htc_operating_mode_t;
typedef enum {
HTC_DATA_AMPDU = 1,
HTC_DATA_NORMAL = 2,
HTC_DATA_BEACON = 3,
HTC_DATA_MGMT = 4
} htc_data_type_t;
typedef struct {
int ctrl_endpoint;
int wmi_endpoint;
int beacon_endpoint;
int cab_endpoint;
int uapsd_endpoint;
int mgmt_endpoint;
int data_be_endpoint;
int data_bk_endpoint;
int data_video_endpoint;
int data_voice_endpoint;
} htc_pipes_t;
typedef struct {
uint16_t sequence_number;
htc_pipes_t endpoints;
fibril_mutex_t rx_lock;
fibril_mutex_t tx_lock;
ieee80211_dev_t *ieee80211_dev;
ath_t *ath_device;
} htc_device_t;
typedef struct {
uint8_t endpoint_id;
uint8_t flags;
uint16_t payload_length;
uint8_t control_bytes[4];
} __attribute__((packed)) htc_frame_header_t;
typedef struct {
uint8_t node_idx;
uint8_t vif_idx;
uint8_t tidno;
uint8_t flags;
uint8_t key_type;
uint8_t keyix;
uint8_t cookie;
uint8_t pad;
} __attribute__((packed)) htc_tx_management_header_t;
typedef struct {
uint8_t data_type;
uint8_t node_idx;
uint8_t vif_idx;
uint8_t tidno;
uint32_t flags;
uint8_t key_type;
uint8_t keyix;
uint8_t cookie;
uint8_t pad;
} __attribute__((packed)) htc_tx_data_header_t;
typedef struct {
uint16_t message_id;
uint16_t credits;
uint16_t credit_size;
uint8_t max_endpoints;
uint8_t pad;
} __attribute__((packed)) htc_ready_msg_t;
typedef struct {
uint16_t message_id;
uint16_t service_id;
uint16_t connection_flags;
uint8_t download_pipe_id;
uint8_t upload_pipe_id;
uint8_t service_meta_length;
uint8_t pad;
} __attribute__((packed)) htc_service_msg_t;
typedef struct {
uint16_t message_id;
uint16_t service_id;
uint8_t status;
uint8_t endpoint_id;
uint16_t max_message_length;
uint8_t service_meta_length;
uint8_t pad;
} __attribute__((packed)) htc_service_resp_msg_t;
typedef struct {
uint16_t message_id;
uint8_t pipe_id;
uint8_t credits;
} __attribute__((packed)) htc_config_msg_t;
typedef struct {
uint8_t index;
uint8_t op_mode;
uint8_t addr[ETH_ADDR];
uint8_t ath_cap;
uint16_t rts_thres;
uint8_t pad;
} __attribute__((packed)) htc_vif_msg_t;
typedef struct {
uint8_t addr[ETH_ADDR];
uint8_t bssid[ETH_ADDR];
uint8_t sta_index;
uint8_t vif_index;
uint8_t is_vif_sta;
uint16_t flags;
uint16_t ht_cap;
uint16_t max_ampdu;
uint8_t pad;
} __attribute__((packed)) htc_sta_msg_t;
typedef struct {
uint32_t ampdu_limit;
uint8_t ampdu_subframes;
uint8_t enable_coex;
uint8_t tx_chainmask;
uint8_t pad;
} __attribute__((packed)) htc_cap_msg_t;
typedef struct {
uint8_t sta_index;
uint8_t is_new;
uint32_t cap_flags;
uint8_t legacy_rates_count;
uint8_t legacy_rates[HTC_RATES_MAX_LENGTH];
uint16_t pad;
} htc_rate_msg_t;
typedef struct {
uint64_t timestamp;
uint16_t data_length;
uint8_t status;
uint8_t phy_err;
int8_t rssi;
int8_t rssi_ctl[3];
int8_t rssi_ext[3];
uint8_t keyix;
uint8_t rate;
uint8_t antenna;
uint8_t more;
uint8_t is_aggr;
uint8_t more_aggr;
uint8_t num_delims;
uint8_t flags;
uint8_t dummy;
uint32_t evm0;
uint32_t evm1;
uint32_t evm2;
} htc_rx_status_t;
typedef struct {
uint16_t message_id;
} __attribute__((packed)) htc_setup_complete_msg_t;
extern errno_t htc_device_init(ath_t *, ieee80211_dev_t *, htc_device_t *);
extern errno_t htc_init(htc_device_t *);
extern errno_t htc_init_new_vif(htc_device_t *);
extern errno_t htc_read_control_message(htc_device_t *, void *, size_t, size_t *);
extern errno_t htc_read_data_message(htc_device_t *, void *, size_t, size_t *);
extern errno_t htc_send_control_message(htc_device_t *, void *, size_t, uint8_t);
extern errno_t htc_send_data_message(htc_device_t *, void *, size_t, uint8_t);
#endif
HelenOS homepage, sources at GitHub