1 2 3#ifndef __i1480_wlp_h__ 4#define __i1480_wlp_h__ 5 6#include <linux/spinlock.h> 7#include <linux/list.h> 8#include <linux/uwb.h> 9#include <linux/if_ether.h> 10#include <asm/byteorder.h> 11 12/* New simplified header format? */ 13#undef WLP_HDR_FMT_2 14 15/** 16 * Values of the Delivery ID & Type field when PCA or DRP 17 * 18 * The Delivery ID & Type field in the WLP TX header indicates whether 19 * the frame is PCA or DRP. This is done based on the high level bit of 20 * this field. 21 * We use this constant to test if the traffic is PCA or DRP as follows: 22 * if (wlp_tx_hdr_delivery_id_type(wlp_tx_hdr) & WLP_DRP) 23 * this is DRP traffic 24 * else 25 * this is PCA traffic 26 */ 27enum deliver_id_type_bit { 28 WLP_DRP = 8, 29}; 30 31/** 32 * WLP TX header 33 * 34 * Indicates UWB/WLP-specific transmission parameters for a network 35 * packet. 36 */ 37struct wlp_tx_hdr { 38 /* dword 0 */ 39 struct uwb_dev_addr dstaddr; 40 u8 key_index; 41 u8 mac_params; 42 /* dword 1 */ 43 u8 phy_params; 44#ifndef WLP_HDR_FMT_2 45 u8 reserved; 46 __le16 oui01; 47 /* dword 2 */ 48 u8 oui2; /* if all LE, it could be merged */ 49 __le16 prid; 50#endif 51} __attribute__((packed)); 52 53static inline int wlp_tx_hdr_delivery_id_type(const struct wlp_tx_hdr *hdr) 54{ 55 return hdr->mac_params & 0x0f; 56} 57 58static inline int wlp_tx_hdr_ack_policy(const struct wlp_tx_hdr *hdr) 59{ 60 return (hdr->mac_params >> 4) & 0x07; 61} 62 63static inline int wlp_tx_hdr_rts_cts(const struct wlp_tx_hdr *hdr) 64{ 65 return (hdr->mac_params >> 7) & 0x01; 66} 67 68static inline void wlp_tx_hdr_set_delivery_id_type(struct wlp_tx_hdr *hdr, int id) 69{ 70 hdr->mac_params = (hdr->mac_params & ~0x0f) | id; 71} 72 73static inline void wlp_tx_hdr_set_ack_policy(struct wlp_tx_hdr *hdr, 74 enum uwb_ack_pol policy) 75{ 76 hdr->mac_params = (hdr->mac_params & ~0x70) | (policy << 4); 77} 78 79static inline void wlp_tx_hdr_set_rts_cts(struct wlp_tx_hdr *hdr, int rts_cts) 80{ 81 hdr->mac_params = (hdr->mac_params & ~0x80) | (rts_cts << 7); 82} 83 84static inline enum uwb_phy_rate wlp_tx_hdr_phy_rate(const struct wlp_tx_hdr *hdr) 85{ 86 return hdr->phy_params & 0x0f; 87} 88 89static inline int wlp_tx_hdr_tx_power(const struct wlp_tx_hdr *hdr) 90{ 91 return (hdr->phy_params >> 4) & 0x0f; 92} 93 94static inline void wlp_tx_hdr_set_phy_rate(struct wlp_tx_hdr *hdr, enum uwb_phy_rate rate) 95{ 96 hdr->phy_params = (hdr->phy_params & ~0x0f) | rate; 97} 98 99static inline void wlp_tx_hdr_set_tx_power(struct wlp_tx_hdr *hdr, int pwr) 100{ 101 hdr->phy_params = (hdr->phy_params & ~0xf0) | (pwr << 4); 102} 103 104 105/** 106 * WLP RX header 107 * 108 * Provides UWB/WLP-specific transmission data for a received 109 * network packet. 110 */ 111struct wlp_rx_hdr { 112 /* dword 0 */ 113 struct uwb_dev_addr dstaddr; 114 struct uwb_dev_addr srcaddr; 115 /* dword 1 */ 116 u8 LQI; 117 s8 RSSI; 118 u8 reserved3; 119#ifndef WLP_HDR_FMT_2 120 u8 oui0; 121 /* dword 2 */ 122 __le16 oui12; 123 __le16 prid; 124#endif 125} __attribute__((packed)); 126 127 128/** User configurable options for WLP */ 129struct wlp_options { 130 struct mutex mutex; /* access to user configurable options*/ 131 struct wlp_tx_hdr def_tx_hdr; /* default tx hdr */ 132 u8 pca_base_priority; 133 u8 bw_alloc; /*index into bw_allocs[] for PCA/DRP reservations*/ 134}; 135 136 137static inline 138void wlp_options_init(struct wlp_options *options) 139{ 140 mutex_init(&options->mutex); 141 wlp_tx_hdr_set_ack_policy(&options->def_tx_hdr, UWB_ACK_INM); 142 wlp_tx_hdr_set_rts_cts(&options->def_tx_hdr, 1); 143 wlp_tx_hdr_set_phy_rate(&options->def_tx_hdr, UWB_PHY_RATE_480); 144#ifndef WLP_HDR_FMT_2 145 options->def_tx_hdr.prid = cpu_to_le16(0x0000); 146#endif 147} 148 149 150/* sysfs helpers */ 151 152extern ssize_t uwb_pca_base_priority_store(struct wlp_options *, 153 const char *, size_t); 154extern ssize_t uwb_pca_base_priority_show(const struct wlp_options *, char *); 155extern ssize_t uwb_bw_alloc_store(struct wlp_options *, const char *, size_t); 156extern ssize_t uwb_bw_alloc_show(const struct wlp_options *, char *); 157extern ssize_t uwb_ack_policy_store(struct wlp_options *, 158 const char *, size_t); 159extern ssize_t uwb_ack_policy_show(const struct wlp_options *, char *); 160extern ssize_t uwb_rts_cts_store(struct wlp_options *, const char *, size_t); 161extern ssize_t uwb_rts_cts_show(const struct wlp_options *, char *); 162extern ssize_t uwb_phy_rate_store(struct wlp_options *, const char *, size_t); 163extern ssize_t uwb_phy_rate_show(const struct wlp_options *, char *); 164 165 166/** Simple bandwidth allocation (temporary and too simple) */ 167struct wlp_bw_allocs { 168 const char *name; 169 struct { 170 u8 mask, stream; 171 } tx, rx; 172}; 173 174 175#endif /* #ifndef __i1480_wlp_h__ */ 176