diff options
Diffstat (limited to 'drivers/uwb/wlp/txrx.c')
-rw-r--r-- | drivers/uwb/wlp/txrx.c | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/drivers/uwb/wlp/txrx.c b/drivers/uwb/wlp/txrx.c index c701bd1a2887..cd2035768b47 100644 --- a/drivers/uwb/wlp/txrx.c +++ b/drivers/uwb/wlp/txrx.c | |||
@@ -26,12 +26,10 @@ | |||
26 | 26 | ||
27 | #include <linux/etherdevice.h> | 27 | #include <linux/etherdevice.h> |
28 | #include <linux/wlp.h> | 28 | #include <linux/wlp.h> |
29 | #define D_LOCAL 5 | ||
30 | #include <linux/uwb/debug.h> | ||
31 | #include "wlp-internal.h" | ||
32 | 29 | ||
30 | #include "wlp-internal.h" | ||
33 | 31 | ||
34 | /** | 32 | /* |
35 | * Direct incoming association msg to correct parsing routine | 33 | * Direct incoming association msg to correct parsing routine |
36 | * | 34 | * |
37 | * We only expect D1, E1, C1, C3 messages as new. All other incoming | 35 | * We only expect D1, E1, C1, C3 messages as new. All other incoming |
@@ -48,35 +46,31 @@ void wlp_direct_assoc_frame(struct wlp *wlp, struct sk_buff *skb, | |||
48 | struct device *dev = &wlp->rc->uwb_dev.dev; | 46 | struct device *dev = &wlp->rc->uwb_dev.dev; |
49 | struct wlp_frame_assoc *assoc = (void *) skb->data; | 47 | struct wlp_frame_assoc *assoc = (void *) skb->data; |
50 | struct wlp_assoc_frame_ctx *frame_ctx; | 48 | struct wlp_assoc_frame_ctx *frame_ctx; |
51 | d_fnstart(5, dev, "wlp %p, skb %p\n", wlp, skb); | 49 | |
52 | frame_ctx = kmalloc(sizeof(*frame_ctx), GFP_ATOMIC); | 50 | frame_ctx = kmalloc(sizeof(*frame_ctx), GFP_ATOMIC); |
53 | if (frame_ctx == NULL) { | 51 | if (frame_ctx == NULL) { |
54 | dev_err(dev, "WLP: Unable to allocate memory for association " | 52 | dev_err(dev, "WLP: Unable to allocate memory for association " |
55 | "frame handling.\n"); | 53 | "frame handling.\n"); |
56 | kfree_skb(skb); | 54 | kfree_skb(skb); |
57 | goto out; | 55 | return; |
58 | } | 56 | } |
59 | frame_ctx->wlp = wlp; | 57 | frame_ctx->wlp = wlp; |
60 | frame_ctx->skb = skb; | 58 | frame_ctx->skb = skb; |
61 | frame_ctx->src = *src; | 59 | frame_ctx->src = *src; |
62 | switch (assoc->type) { | 60 | switch (assoc->type) { |
63 | case WLP_ASSOC_D1: | 61 | case WLP_ASSOC_D1: |
64 | d_printf(5, dev, "Received a D1 frame.\n"); | ||
65 | INIT_WORK(&frame_ctx->ws, wlp_handle_d1_frame); | 62 | INIT_WORK(&frame_ctx->ws, wlp_handle_d1_frame); |
66 | schedule_work(&frame_ctx->ws); | 63 | schedule_work(&frame_ctx->ws); |
67 | break; | 64 | break; |
68 | case WLP_ASSOC_E1: | 65 | case WLP_ASSOC_E1: |
69 | d_printf(5, dev, "Received a E1 frame. FIXME?\n"); | ||
70 | kfree_skb(skb); /* Temporary until we handle it */ | 66 | kfree_skb(skb); /* Temporary until we handle it */ |
71 | kfree(frame_ctx); /* Temporary until we handle it */ | 67 | kfree(frame_ctx); /* Temporary until we handle it */ |
72 | break; | 68 | break; |
73 | case WLP_ASSOC_C1: | 69 | case WLP_ASSOC_C1: |
74 | d_printf(5, dev, "Received a C1 frame.\n"); | ||
75 | INIT_WORK(&frame_ctx->ws, wlp_handle_c1_frame); | 70 | INIT_WORK(&frame_ctx->ws, wlp_handle_c1_frame); |
76 | schedule_work(&frame_ctx->ws); | 71 | schedule_work(&frame_ctx->ws); |
77 | break; | 72 | break; |
78 | case WLP_ASSOC_C3: | 73 | case WLP_ASSOC_C3: |
79 | d_printf(5, dev, "Received a C3 frame.\n"); | ||
80 | INIT_WORK(&frame_ctx->ws, wlp_handle_c3_frame); | 74 | INIT_WORK(&frame_ctx->ws, wlp_handle_c3_frame); |
81 | schedule_work(&frame_ctx->ws); | 75 | schedule_work(&frame_ctx->ws); |
82 | break; | 76 | break; |
@@ -87,11 +81,9 @@ void wlp_direct_assoc_frame(struct wlp *wlp, struct sk_buff *skb, | |||
87 | kfree(frame_ctx); | 81 | kfree(frame_ctx); |
88 | break; | 82 | break; |
89 | } | 83 | } |
90 | out: | ||
91 | d_fnend(5, dev, "wlp %p\n", wlp); | ||
92 | } | 84 | } |
93 | 85 | ||
94 | /** | 86 | /* |
95 | * Process incoming association frame | 87 | * Process incoming association frame |
96 | * | 88 | * |
97 | * Although it could be possible to deal with some incoming association | 89 | * Although it could be possible to deal with some incoming association |
@@ -112,7 +104,6 @@ void wlp_receive_assoc_frame(struct wlp *wlp, struct sk_buff *skb, | |||
112 | struct wlp_frame_assoc *assoc = (void *) skb->data; | 104 | struct wlp_frame_assoc *assoc = (void *) skb->data; |
113 | struct wlp_session *session = wlp->session; | 105 | struct wlp_session *session = wlp->session; |
114 | u8 version; | 106 | u8 version; |
115 | d_fnstart(5, dev, "wlp %p, skb %p\n", wlp, skb); | ||
116 | 107 | ||
117 | if (wlp_get_version(wlp, &assoc->version, &version, | 108 | if (wlp_get_version(wlp, &assoc->version, &version, |
118 | sizeof(assoc->version)) < 0) | 109 | sizeof(assoc->version)) < 0) |
@@ -150,14 +141,12 @@ void wlp_receive_assoc_frame(struct wlp *wlp, struct sk_buff *skb, | |||
150 | } else { | 141 | } else { |
151 | wlp_direct_assoc_frame(wlp, skb, src); | 142 | wlp_direct_assoc_frame(wlp, skb, src); |
152 | } | 143 | } |
153 | d_fnend(5, dev, "wlp %p\n", wlp); | ||
154 | return; | 144 | return; |
155 | error: | 145 | error: |
156 | kfree_skb(skb); | 146 | kfree_skb(skb); |
157 | d_fnend(5, dev, "wlp %p\n", wlp); | ||
158 | } | 147 | } |
159 | 148 | ||
160 | /** | 149 | /* |
161 | * Verify incoming frame is from connected neighbor, prep to pass to WLP client | 150 | * Verify incoming frame is from connected neighbor, prep to pass to WLP client |
162 | * | 151 | * |
163 | * Verification proceeds according to WLP 0.99 [7.3.1]. The source address | 152 | * Verification proceeds according to WLP 0.99 [7.3.1]. The source address |
@@ -176,7 +165,6 @@ int wlp_verify_prep_rx_frame(struct wlp *wlp, struct sk_buff *skb, | |||
176 | struct wlp_eda_node eda_entry; | 165 | struct wlp_eda_node eda_entry; |
177 | struct wlp_frame_std_abbrv_hdr *hdr = (void *) skb->data; | 166 | struct wlp_frame_std_abbrv_hdr *hdr = (void *) skb->data; |
178 | 167 | ||
179 | d_fnstart(6, dev, "wlp %p, skb %p \n", wlp, skb); | ||
180 | /*verify*/ | 168 | /*verify*/ |
181 | result = wlp_copy_eda_node(&wlp->eda, src, &eda_entry); | 169 | result = wlp_copy_eda_node(&wlp->eda, src, &eda_entry); |
182 | if (result < 0) { | 170 | if (result < 0) { |
@@ -207,11 +195,10 @@ int wlp_verify_prep_rx_frame(struct wlp *wlp, struct sk_buff *skb, | |||
207 | /*prep*/ | 195 | /*prep*/ |
208 | skb_pull(skb, sizeof(*hdr)); | 196 | skb_pull(skb, sizeof(*hdr)); |
209 | out: | 197 | out: |
210 | d_fnend(6, dev, "wlp %p, skb %p, result = %d \n", wlp, skb, result); | ||
211 | return result; | 198 | return result; |
212 | } | 199 | } |
213 | 200 | ||
214 | /** | 201 | /* |
215 | * Receive a WLP frame from device | 202 | * Receive a WLP frame from device |
216 | * | 203 | * |
217 | * @returns: 1 if calling function should free the skb | 204 | * @returns: 1 if calling function should free the skb |
@@ -226,14 +213,12 @@ int wlp_receive_frame(struct device *dev, struct wlp *wlp, struct sk_buff *skb, | |||
226 | struct wlp_frame_hdr *hdr; | 213 | struct wlp_frame_hdr *hdr; |
227 | int result = 0; | 214 | int result = 0; |
228 | 215 | ||
229 | d_fnstart(6, dev, "skb (%p), len (%u)\n", skb, len); | ||
230 | if (len < sizeof(*hdr)) { | 216 | if (len < sizeof(*hdr)) { |
231 | dev_err(dev, "Not enough data to parse WLP header.\n"); | 217 | dev_err(dev, "Not enough data to parse WLP header.\n"); |
232 | result = -EINVAL; | 218 | result = -EINVAL; |
233 | goto out; | 219 | goto out; |
234 | } | 220 | } |
235 | hdr = ptr; | 221 | hdr = ptr; |
236 | d_dump(6, dev, hdr, sizeof(*hdr)); | ||
237 | if (le16_to_cpu(hdr->mux_hdr) != WLP_PROTOCOL_ID) { | 222 | if (le16_to_cpu(hdr->mux_hdr) != WLP_PROTOCOL_ID) { |
238 | dev_err(dev, "Not a WLP frame type.\n"); | 223 | dev_err(dev, "Not a WLP frame type.\n"); |
239 | result = -EINVAL; | 224 | result = -EINVAL; |
@@ -270,7 +255,6 @@ int wlp_receive_frame(struct device *dev, struct wlp *wlp, struct sk_buff *skb, | |||
270 | "WLP header.\n"); | 255 | "WLP header.\n"); |
271 | goto out; | 256 | goto out; |
272 | } | 257 | } |
273 | d_printf(5, dev, "Association frame received.\n"); | ||
274 | wlp_receive_assoc_frame(wlp, skb, src); | 258 | wlp_receive_assoc_frame(wlp, skb, src); |
275 | break; | 259 | break; |
276 | default: | 260 | default: |
@@ -283,13 +267,12 @@ out: | |||
283 | kfree_skb(skb); | 267 | kfree_skb(skb); |
284 | result = 0; | 268 | result = 0; |
285 | } | 269 | } |
286 | d_fnend(6, dev, "skb (%p)\n", skb); | ||
287 | return result; | 270 | return result; |
288 | } | 271 | } |
289 | EXPORT_SYMBOL_GPL(wlp_receive_frame); | 272 | EXPORT_SYMBOL_GPL(wlp_receive_frame); |
290 | 273 | ||
291 | 274 | ||
292 | /** | 275 | /* |
293 | * Verify frame from network stack, prepare for further transmission | 276 | * Verify frame from network stack, prepare for further transmission |
294 | * | 277 | * |
295 | * @skb: the socket buffer that needs to be prepared for transmission (it | 278 | * @skb: the socket buffer that needs to be prepared for transmission (it |
@@ -343,9 +326,7 @@ int wlp_prepare_tx_frame(struct device *dev, struct wlp *wlp, | |||
343 | int result = -EINVAL; | 326 | int result = -EINVAL; |
344 | struct ethhdr *eth_hdr = (void *) skb->data; | 327 | struct ethhdr *eth_hdr = (void *) skb->data; |
345 | 328 | ||
346 | d_fnstart(6, dev, "wlp (%p), skb (%p) \n", wlp, skb); | ||
347 | if (is_broadcast_ether_addr(eth_hdr->h_dest)) { | 329 | if (is_broadcast_ether_addr(eth_hdr->h_dest)) { |
348 | d_printf(6, dev, "WLP: handling broadcast frame. \n"); | ||
349 | result = wlp_eda_for_each(&wlp->eda, wlp_wss_send_copy, skb); | 330 | result = wlp_eda_for_each(&wlp->eda, wlp_wss_send_copy, skb); |
350 | if (result < 0) { | 331 | if (result < 0) { |
351 | if (printk_ratelimit()) | 332 | if (printk_ratelimit()) |
@@ -357,7 +338,6 @@ int wlp_prepare_tx_frame(struct device *dev, struct wlp *wlp, | |||
357 | result = 1; | 338 | result = 1; |
358 | /* Frame will be transmitted by WLP. */ | 339 | /* Frame will be transmitted by WLP. */ |
359 | } else { | 340 | } else { |
360 | d_printf(6, dev, "WLP: handling unicast frame. \n"); | ||
361 | result = wlp_eda_for_virtual(&wlp->eda, eth_hdr->h_dest, dst, | 341 | result = wlp_eda_for_virtual(&wlp->eda, eth_hdr->h_dest, dst, |
362 | wlp_wss_prep_hdr, skb); | 342 | wlp_wss_prep_hdr, skb); |
363 | if (unlikely(result < 0)) { | 343 | if (unlikely(result < 0)) { |
@@ -368,7 +348,6 @@ int wlp_prepare_tx_frame(struct device *dev, struct wlp *wlp, | |||
368 | } | 348 | } |
369 | } | 349 | } |
370 | out: | 350 | out: |
371 | d_fnend(6, dev, "wlp (%p), skb (%p). result = %d \n", wlp, skb, result); | ||
372 | return result; | 351 | return result; |
373 | } | 352 | } |
374 | EXPORT_SYMBOL_GPL(wlp_prepare_tx_frame); | 353 | EXPORT_SYMBOL_GPL(wlp_prepare_tx_frame); |