2 * Intel Wireless WiMAX Connection 2400m
3 * Handle incoming traffic and deliver it to the control or data planes
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 * Intel Corporation <linux-wimax@intel.com>
36 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
37 * - Initial implementation
38 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
39 * - Use skb_clone(), break up processing in chunks
40 * - Split transport/device specific
41 * - Make buffer size dynamic to exert less memory pressure
42 * - RX reorder support
44 * This handles the RX path.
46 * We receive an RX message from the bus-specific driver, which
47 * contains one or more payloads that have potentially different
48 * destinataries (data or control paths).
50 * So we just take that payload from the transport specific code in
51 * the form of an skb, break it up in chunks (a cloned skb each in the
52 * case of network packets) and pass it to netdev or to the
53 * command/ack handler (and from there to the WiMAX stack).
57 * The format of the buffer is:
59 * HEADER (struct i2400m_msg_hdr)
60 * PAYLOAD DESCRIPTOR 0 (struct i2400m_pld)
61 * PAYLOAD DESCRIPTOR 1
63 * PAYLOAD DESCRIPTOR N
64 * PAYLOAD 0 (raw bytes)
69 * See tx.c for a deeper description on alignment requirements and
70 * other fun facts of it.
74 * In firmwares <= v1.3, data packets have no header for RX, but they
75 * do for TX (currently unused).
77 * In firmware >= 1.4, RX packets have an extended header (16
78 * bytes). This header conveys information for management of host
79 * reordering of packets (the device offloads storage of the packets
80 * for reordering to the host). Read below for more information.
82 * The header is used as dummy space to emulate an ethernet header and
83 * thus be able to act as an ethernet device without having to reallocate.
87 * Starting in firmware v1.4, the device can deliver packets for
88 * delivery with special reordering information; this allows it to
89 * more effectively do packet management when some frames were lost in
92 * Thus, for RX packets that come out of order, the device gives the
93 * driver enough information to queue them properly and then at some
94 * point, the signal to deliver the whole (or part) of the queued
95 * packets to the networking stack. There are 16 such queues.
97 * This only happens when a packet comes in with the "need reorder"
98 * flag set in the RX header. When such bit is set, the following
99 * operations might be indicated:
101 * - reset queue: send all queued packets to the OS
103 * - queue: queue a packet
105 * - update ws: update the queue's window start and deliver queued
106 * packets that meet the criteria
108 * - queue & update ws: queue a packet, update the window start and
109 * deliver queued packets that meet the criteria
111 * (delivery criteria: the packet's [normalized] sequence number is
112 * lower than the new [normalized] window start).
114 * See the i2400m_roq_*() functions for details.
119 * i2400m_rx_msg_hdr_check
120 * i2400m_rx_pl_descr_check
129 * i2400m_roq_update_ws
130 * __i2400m_roq_update_ws
132 * i2400m_roq_queue_update_ws
134 * __i2400m_roq_update_ws
137 * i2400m_msg_size_check
138 * i2400m_report_hook_work [in a workqueue]
142 * wimax_msg_to_user_alloc
144 * i2400m_msg_size_check
147 #include <linux/slab.h>
148 #include <linux/kernel.h>
149 #include <linux/if_arp.h>
150 #include <linux/netdevice.h>
151 #include <linux/workqueue.h>
155 #define D_SUBMODULE rx
156 #include "debug-levels.h"
158 struct i2400m_report_hook_args
{
159 struct sk_buff
*skb_rx
;
160 const struct i2400m_l3l4_hdr
*l3l4_hdr
;
162 struct list_head list_node
;
167 * Execute i2400m_report_hook in a workqueue
169 * Goes over the list of queued reports in i2400m->rx_reports and
172 * NOTE: refcounts on i2400m are not needed because we flush the
173 * workqueue this runs on (i2400m->work_queue) before destroying
176 void i2400m_report_hook_work(struct work_struct
*ws
)
178 struct i2400m
*i2400m
= container_of(ws
, struct i2400m
, rx_report_ws
);
179 struct device
*dev
= i2400m_dev(i2400m
);
180 struct i2400m_report_hook_args
*args
, *args_next
;
185 spin_lock_irqsave(&i2400m
->rx_lock
, flags
);
186 list_splice_init(&i2400m
->rx_reports
, &list
);
187 spin_unlock_irqrestore(&i2400m
->rx_lock
, flags
);
188 if (list_empty(&list
))
191 d_printf(1, dev
, "processing queued reports\n");
192 list_for_each_entry_safe(args
, args_next
, &list
, list_node
) {
193 d_printf(2, dev
, "processing queued report %p\n", args
);
194 i2400m_report_hook(i2400m
, args
->l3l4_hdr
, args
->size
);
195 kfree_skb(args
->skb_rx
);
196 list_del(&args
->list_node
);
204 * Flush the list of queued reports
207 void i2400m_report_hook_flush(struct i2400m
*i2400m
)
209 struct device
*dev
= i2400m_dev(i2400m
);
210 struct i2400m_report_hook_args
*args
, *args_next
;
214 d_printf(1, dev
, "flushing queued reports\n");
215 spin_lock_irqsave(&i2400m
->rx_lock
, flags
);
216 list_splice_init(&i2400m
->rx_reports
, &list
);
217 spin_unlock_irqrestore(&i2400m
->rx_lock
, flags
);
218 list_for_each_entry_safe(args
, args_next
, &list
, list_node
) {
219 d_printf(2, dev
, "flushing queued report %p\n", args
);
220 kfree_skb(args
->skb_rx
);
221 list_del(&args
->list_node
);
228 * Queue a report for later processing
230 * @i2400m: device descriptor
231 * @skb_rx: skb that contains the payload (for reference counting)
232 * @l3l4_hdr: pointer to the control
233 * @size: size of the message
236 void i2400m_report_hook_queue(struct i2400m
*i2400m
, struct sk_buff
*skb_rx
,
237 const void *l3l4_hdr
, size_t size
)
239 struct device
*dev
= i2400m_dev(i2400m
);
241 struct i2400m_report_hook_args
*args
;
243 args
= kzalloc(sizeof(*args
), GFP_NOIO
);
245 args
->skb_rx
= skb_get(skb_rx
);
246 args
->l3l4_hdr
= l3l4_hdr
;
248 spin_lock_irqsave(&i2400m
->rx_lock
, flags
);
249 list_add_tail(&args
->list_node
, &i2400m
->rx_reports
);
250 spin_unlock_irqrestore(&i2400m
->rx_lock
, flags
);
251 d_printf(2, dev
, "queued report %p\n", args
);
252 rmb(); /* see i2400m->ready's documentation */
253 if (likely(i2400m
->ready
)) /* only send if up */
254 queue_work(i2400m
->work_queue
, &i2400m
->rx_report_ws
);
256 if (printk_ratelimit())
257 dev_err(dev
, "%s:%u: Can't allocate %zu B\n",
258 __func__
, __LINE__
, sizeof(*args
));
264 * Process an ack to a command
266 * @i2400m: device descriptor
267 * @payload: pointer to message
268 * @size: size of the message
270 * Pass the acknodledgment (in an skb) to the thread that is waiting
271 * for it in i2400m->msg_completion.
273 * We need to coordinate properly with the thread waiting for the
274 * ack. Check if it is waiting or if it is gone. We loose the spinlock
275 * to avoid allocating on atomic contexts (yeah, could use GFP_ATOMIC,
276 * but this is not so speed critical).
279 void i2400m_rx_ctl_ack(struct i2400m
*i2400m
,
280 const void *payload
, size_t size
)
282 struct device
*dev
= i2400m_dev(i2400m
);
283 struct wimax_dev
*wimax_dev
= &i2400m
->wimax_dev
;
285 struct sk_buff
*ack_skb
;
287 /* Anyone waiting for an answer? */
288 spin_lock_irqsave(&i2400m
->rx_lock
, flags
);
289 if (i2400m
->ack_skb
!= ERR_PTR(-EINPROGRESS
)) {
290 dev_err(dev
, "Huh? reply to command with no waiters\n");
291 goto error_no_waiter
;
293 spin_unlock_irqrestore(&i2400m
->rx_lock
, flags
);
295 ack_skb
= wimax_msg_alloc(wimax_dev
, NULL
, payload
, size
, GFP_KERNEL
);
297 /* Check waiter didn't time out waiting for the answer... */
298 spin_lock_irqsave(&i2400m
->rx_lock
, flags
);
299 if (i2400m
->ack_skb
!= ERR_PTR(-EINPROGRESS
)) {
300 d_printf(1, dev
, "Huh? waiter for command reply cancelled\n");
301 goto error_waiter_cancelled
;
303 if (ack_skb
== NULL
) {
304 dev_err(dev
, "CMD/GET/SET ack: cannot allocate SKB\n");
305 i2400m
->ack_skb
= ERR_PTR(-ENOMEM
);
307 i2400m
->ack_skb
= ack_skb
;
308 spin_unlock_irqrestore(&i2400m
->rx_lock
, flags
);
309 complete(&i2400m
->msg_completion
);
312 error_waiter_cancelled
:
315 spin_unlock_irqrestore(&i2400m
->rx_lock
, flags
);
320 * Receive and process a control payload
322 * @i2400m: device descriptor
323 * @skb_rx: skb that contains the payload (for reference counting)
324 * @payload: pointer to message
325 * @size: size of the message
327 * There are two types of control RX messages: reports (asynchronous,
328 * like your every day interrupts) and 'acks' (reponses to a command,
329 * get or set request).
331 * If it is a report, we run hooks on it (to extract information for
332 * things we need to do in the driver) and then pass it over to the
333 * WiMAX stack to send it to user space.
335 * NOTE: report processing is done in a workqueue specific to the
336 * generic driver, to avoid deadlocks in the system.
338 * If it is not a report, it is an ack to a previously executed
339 * command, set or get, so wake up whoever is waiting for it from
340 * i2400m_msg_to_dev(). i2400m_rx_ctl_ack() takes care of that.
342 * Note that the sizes we pass to other functions from here are the
343 * sizes of the _l3l4_hdr + payload, not full buffer sizes, as we have
344 * verified in _msg_size_check() that they are congruent.
346 * For reports: We can't clone the original skb where the data is
347 * because we need to send this up via netlink; netlink has to add
348 * headers and we can't overwrite what's preceeding the payload...as
349 * it is another message. So we just dup them.
352 void i2400m_rx_ctl(struct i2400m
*i2400m
, struct sk_buff
*skb_rx
,
353 const void *payload
, size_t size
)
356 struct device
*dev
= i2400m_dev(i2400m
);
357 const struct i2400m_l3l4_hdr
*l3l4_hdr
= payload
;
360 result
= i2400m_msg_size_check(i2400m
, l3l4_hdr
, size
);
362 dev_err(dev
, "HW BUG? device sent a bad message: %d\n",
366 msg_type
= le16_to_cpu(l3l4_hdr
->type
);
367 d_printf(1, dev
, "%s 0x%04x: %zu bytes\n",
368 msg_type
& I2400M_MT_REPORT_MASK
? "REPORT" : "CMD/SET/GET",
370 d_dump(2, dev
, l3l4_hdr
, size
);
371 if (msg_type
& I2400M_MT_REPORT_MASK
) {
373 * Process each report
375 * - has to be ran serialized as well
377 * - the handling might force the execution of
378 * commands. That might cause reentrancy issues with
379 * bus-specific subdrivers and workqueues, so the we
380 * run it in a separate workqueue.
382 * - when the driver is not yet ready to handle them,
383 * they are queued and at some point the queue is
384 * restarted [NOTE: we can't queue SKBs directly, as
385 * this might be a piece of a SKB, not the whole
386 * thing, and this is cheaper than cloning the
389 * Note we don't do refcounting for the device
390 * structure; this is because before destroying
391 * 'i2400m', we make sure to flush the
392 * i2400m->work_queue, so there are no issues.
394 i2400m_report_hook_queue(i2400m
, skb_rx
, l3l4_hdr
, size
);
395 if (unlikely(i2400m
->trace_msg_from_user
))
396 wimax_msg(&i2400m
->wimax_dev
, "echo",
397 l3l4_hdr
, size
, GFP_KERNEL
);
398 result
= wimax_msg(&i2400m
->wimax_dev
, NULL
, l3l4_hdr
, size
,
401 dev_err(dev
, "error sending report to userspace: %d\n",
403 } else /* an ack to a CMD, GET or SET */
404 i2400m_rx_ctl_ack(i2400m
, payload
, size
);
411 * Receive and send up a trace
413 * @i2400m: device descriptor
414 * @skb_rx: skb that contains the trace (for reference counting)
415 * @payload: pointer to trace message inside the skb
416 * @size: size of the message
418 * THe i2400m might produce trace information (diagnostics) and we
419 * send them through a different kernel-to-user pipe (to avoid
422 * As in i2400m_rx_ctl(), we can't clone the original skb where the
423 * data is because we need to send this up via netlink; netlink has to
424 * add headers and we can't overwrite what's preceeding the
425 * payload...as it is another message. So we just dup them.
428 void i2400m_rx_trace(struct i2400m
*i2400m
,
429 const void *payload
, size_t size
)
432 struct device
*dev
= i2400m_dev(i2400m
);
433 struct wimax_dev
*wimax_dev
= &i2400m
->wimax_dev
;
434 const struct i2400m_l3l4_hdr
*l3l4_hdr
= payload
;
437 result
= i2400m_msg_size_check(i2400m
, l3l4_hdr
, size
);
439 dev_err(dev
, "HW BUG? device sent a bad trace message: %d\n",
443 msg_type
= le16_to_cpu(l3l4_hdr
->type
);
444 d_printf(1, dev
, "Trace %s 0x%04x: %zu bytes\n",
445 msg_type
& I2400M_MT_REPORT_MASK
? "REPORT" : "CMD/SET/GET",
447 d_dump(2, dev
, l3l4_hdr
, size
);
448 result
= wimax_msg(wimax_dev
, "trace", l3l4_hdr
, size
, GFP_KERNEL
);
450 dev_err(dev
, "error sending trace to userspace: %d\n",
458 * Reorder queue data stored on skb->cb while the skb is queued in the
461 struct i2400m_roq_data
{
462 unsigned sn
; /* Serial number for the skb */
463 enum i2400m_cs cs
; /* packet type for the skb */
470 * @ws: Window Start; sequence number where the current window start
472 * @queue: the skb queue itself
473 * @log: circular ring buffer used to log information about the
474 * reorder process in this queue that can be displayed in case of
475 * error to help diagnose it.
477 * This is the head for a list of skbs. In the skb->cb member of the
478 * skb when queued here contains a 'struct i2400m_roq_data' were we
479 * store the sequence number (sn) and the cs (packet type) coming from
480 * the RX payload header from the device.
485 struct sk_buff_head queue
;
486 struct i2400m_roq_log
*log
;
491 void __i2400m_roq_init(struct i2400m_roq
*roq
)
494 skb_queue_head_init(&roq
->queue
);
499 unsigned __i2400m_roq_index(struct i2400m
*i2400m
, struct i2400m_roq
*roq
)
501 return ((unsigned long) roq
- (unsigned long) i2400m
->rx_roq
)
507 * Normalize a sequence number based on the queue's window start
509 * nsn = (sn - ws) % 2048
511 * Note that if @sn < @roq->ws, we still need a positive number; %'s
512 * sign is implementation specific, so we normalize it by adding 2048
513 * to bring it to be positive.
516 unsigned __i2400m_roq_nsn(struct i2400m_roq
*roq
, unsigned sn
)
519 r
= ((int) sn
- (int) roq
->ws
) % 2048;
527 * Circular buffer to keep the last N reorder operations
529 * In case something fails, dumb then to try to come up with what
533 I2400M_ROQ_LOG_LENGTH
= 32,
536 struct i2400m_roq_log
{
537 struct i2400m_roq_log_entry
{
538 enum i2400m_ro_type type
;
539 unsigned ws
, count
, sn
, nsn
, new_ws
;
540 } entry
[I2400M_ROQ_LOG_LENGTH
];
545 /* Print a log entry */
547 void i2400m_roq_log_entry_print(struct i2400m
*i2400m
, unsigned index
,
549 struct i2400m_roq_log_entry
*e
)
551 struct device
*dev
= i2400m_dev(i2400m
);
554 case I2400M_RO_TYPE_RESET
:
555 dev_err(dev
, "q#%d reset ws %u cnt %u sn %u/%u"
557 index
, e
->ws
, e
->count
, e
->sn
, e
->nsn
, e
->new_ws
);
559 case I2400M_RO_TYPE_PACKET
:
560 dev_err(dev
, "q#%d queue ws %u cnt %u sn %u/%u\n",
561 index
, e
->ws
, e
->count
, e
->sn
, e
->nsn
);
563 case I2400M_RO_TYPE_WS
:
564 dev_err(dev
, "q#%d update_ws ws %u cnt %u sn %u/%u"
566 index
, e
->ws
, e
->count
, e
->sn
, e
->nsn
, e
->new_ws
);
568 case I2400M_RO_TYPE_PACKET_WS
:
569 dev_err(dev
, "q#%d queue_update_ws ws %u cnt %u sn %u/%u"
571 index
, e
->ws
, e
->count
, e
->sn
, e
->nsn
, e
->new_ws
);
574 dev_err(dev
, "q#%d BUG? entry %u - unknown type %u\n",
575 index
, e_index
, e
->type
);
582 void i2400m_roq_log_add(struct i2400m
*i2400m
,
583 struct i2400m_roq
*roq
, enum i2400m_ro_type type
,
584 unsigned ws
, unsigned count
, unsigned sn
,
585 unsigned nsn
, unsigned new_ws
)
587 struct i2400m_roq_log_entry
*e
;
589 int index
= __i2400m_roq_index(i2400m
, roq
);
591 /* if we run out of space, we eat from the end */
592 if (roq
->log
->in
- roq
->log
->out
== I2400M_ROQ_LOG_LENGTH
)
594 cnt_idx
= roq
->log
->in
++ % I2400M_ROQ_LOG_LENGTH
;
595 e
= &roq
->log
->entry
[cnt_idx
];
605 i2400m_roq_log_entry_print(i2400m
, index
, cnt_idx
, e
);
609 /* Dump all the entries in the FIFO and reinitialize it */
611 void i2400m_roq_log_dump(struct i2400m
*i2400m
, struct i2400m_roq
*roq
)
613 unsigned cnt
, cnt_idx
;
614 struct i2400m_roq_log_entry
*e
;
615 int index
= __i2400m_roq_index(i2400m
, roq
);
617 BUG_ON(roq
->log
->out
> roq
->log
->in
);
618 for (cnt
= roq
->log
->out
; cnt
< roq
->log
->in
; cnt
++) {
619 cnt_idx
= cnt
% I2400M_ROQ_LOG_LENGTH
;
620 e
= &roq
->log
->entry
[cnt_idx
];
621 i2400m_roq_log_entry_print(i2400m
, index
, cnt_idx
, e
);
622 memset(e
, 0, sizeof(*e
));
624 roq
->log
->in
= roq
->log
->out
= 0;
629 * Backbone for the queuing of an skb (by normalized sequence number)
631 * @i2400m: device descriptor
632 * @roq: reorder queue where to add
633 * @skb: the skb to add
634 * @sn: the sequence number of the skb
635 * @nsn: the normalized sequence number of the skb (pre-computed by the
636 * caller from the @sn and @roq->ws).
638 * We try first a couple of quick cases:
640 * - the queue is empty
641 * - the skb would be appended to the queue
643 * These will be the most common operations.
645 * If these fail, then we have to do a sorted insertion in the queue,
646 * which is the slowest path.
648 * We don't have to acquire a reference count as we are going to own it.
651 void __i2400m_roq_queue(struct i2400m
*i2400m
, struct i2400m_roq
*roq
,
652 struct sk_buff
*skb
, unsigned sn
, unsigned nsn
)
654 struct device
*dev
= i2400m_dev(i2400m
);
655 struct sk_buff
*skb_itr
;
656 struct i2400m_roq_data
*roq_data_itr
, *roq_data
;
659 d_fnstart(4, dev
, "(i2400m %p roq %p skb %p sn %u nsn %u)\n",
660 i2400m
, roq
, skb
, sn
, nsn
);
662 roq_data
= (struct i2400m_roq_data
*) &skb
->cb
;
663 BUILD_BUG_ON(sizeof(*roq_data
) > sizeof(skb
->cb
));
665 d_printf(3, dev
, "ERX: roq %p [ws %u] nsn %d sn %u\n",
666 roq
, roq
->ws
, nsn
, roq_data
->sn
);
668 /* Queues will be empty on not-so-bad environments, so try
670 if (skb_queue_empty(&roq
->queue
)) {
671 d_printf(2, dev
, "ERX: roq %p - first one\n", roq
);
672 __skb_queue_head(&roq
->queue
, skb
);
675 /* Now try append, as most of the operations will be that */
676 skb_itr
= skb_peek_tail(&roq
->queue
);
677 roq_data_itr
= (struct i2400m_roq_data
*) &skb_itr
->cb
;
678 nsn_itr
= __i2400m_roq_nsn(roq
, roq_data_itr
->sn
);
679 /* NSN bounds assumed correct (checked when it was queued) */
680 if (nsn
>= nsn_itr
) {
681 d_printf(2, dev
, "ERX: roq %p - appended after %p (nsn %d sn %u)\n",
682 roq
, skb_itr
, nsn_itr
, roq_data_itr
->sn
);
683 __skb_queue_tail(&roq
->queue
, skb
);
686 /* None of the fast paths option worked. Iterate to find the
687 * right spot where to insert the packet; we know the queue is
688 * not empty, so we are not the first ones; we also know we
689 * are not going to be the last ones. The list is sorted, so
690 * we have to insert before the the first guy with an nsn_itr
691 * greater that our nsn. */
692 skb_queue_walk(&roq
->queue
, skb_itr
) {
693 roq_data_itr
= (struct i2400m_roq_data
*) &skb_itr
->cb
;
694 nsn_itr
= __i2400m_roq_nsn(roq
, roq_data_itr
->sn
);
695 /* NSN bounds assumed correct (checked when it was queued) */
697 d_printf(2, dev
, "ERX: roq %p - queued before %p "
698 "(nsn %d sn %u)\n", roq
, skb_itr
, nsn_itr
,
700 __skb_queue_before(&roq
->queue
, skb_itr
, skb
);
704 /* If we get here, that is VERY bad -- print info to help
705 * diagnose and crash it */
706 dev_err(dev
, "SW BUG? failed to insert packet\n");
707 dev_err(dev
, "ERX: roq %p [ws %u] skb %p nsn %d sn %u\n",
708 roq
, roq
->ws
, skb
, nsn
, roq_data
->sn
);
709 skb_queue_walk(&roq
->queue
, skb_itr
) {
710 roq_data_itr
= (struct i2400m_roq_data
*) &skb_itr
->cb
;
711 nsn_itr
= __i2400m_roq_nsn(roq
, roq_data_itr
->sn
);
712 /* NSN bounds assumed correct (checked when it was queued) */
713 dev_err(dev
, "ERX: roq %p skb_itr %p nsn %d sn %u\n",
714 roq
, skb_itr
, nsn_itr
, roq_data_itr
->sn
);
718 d_fnend(4, dev
, "(i2400m %p roq %p skb %p sn %u nsn %d) = void\n",
719 i2400m
, roq
, skb
, sn
, nsn
);
724 * Backbone for the update window start operation
726 * @i2400m: device descriptor
727 * @roq: Reorder queue
728 * @sn: New sequence number
730 * Updates the window start of a queue; when doing so, it must deliver
731 * to the networking stack all the queued skb's whose normalized
732 * sequence number is lower than the new normalized window start.
735 unsigned __i2400m_roq_update_ws(struct i2400m
*i2400m
, struct i2400m_roq
*roq
,
738 struct device
*dev
= i2400m_dev(i2400m
);
739 struct sk_buff
*skb_itr
, *tmp_itr
;
740 struct i2400m_roq_data
*roq_data_itr
;
741 unsigned new_nws
, nsn_itr
;
743 new_nws
= __i2400m_roq_nsn(roq
, sn
);
744 if (unlikely(new_nws
>= 1024) && d_test(1)) {
745 dev_err(dev
, "SW BUG? __update_ws new_nws %u (sn %u ws %u)\n",
746 new_nws
, sn
, roq
->ws
);
748 i2400m_roq_log_dump(i2400m
, roq
);
750 skb_queue_walk_safe(&roq
->queue
, skb_itr
, tmp_itr
) {
751 roq_data_itr
= (struct i2400m_roq_data
*) &skb_itr
->cb
;
752 nsn_itr
= __i2400m_roq_nsn(roq
, roq_data_itr
->sn
);
753 /* NSN bounds assumed correct (checked when it was queued) */
754 if (nsn_itr
< new_nws
) {
755 d_printf(2, dev
, "ERX: roq %p - release skb %p "
756 "(nsn %u/%u new nws %u)\n",
757 roq
, skb_itr
, nsn_itr
, roq_data_itr
->sn
,
759 __skb_unlink(skb_itr
, &roq
->queue
);
760 i2400m_net_erx(i2400m
, skb_itr
, roq_data_itr
->cs
);
763 break; /* rest of packets all nsn_itr > nws */
773 * @i2400m: device descriptor
776 * Deliver all the packets and reset the window-start to zero. Name is
777 * kind of misleading.
780 void i2400m_roq_reset(struct i2400m
*i2400m
, struct i2400m_roq
*roq
)
782 struct device
*dev
= i2400m_dev(i2400m
);
783 struct sk_buff
*skb_itr
, *tmp_itr
;
784 struct i2400m_roq_data
*roq_data_itr
;
786 d_fnstart(2, dev
, "(i2400m %p roq %p)\n", i2400m
, roq
);
787 i2400m_roq_log_add(i2400m
, roq
, I2400M_RO_TYPE_RESET
,
788 roq
->ws
, skb_queue_len(&roq
->queue
),
790 skb_queue_walk_safe(&roq
->queue
, skb_itr
, tmp_itr
) {
791 roq_data_itr
= (struct i2400m_roq_data
*) &skb_itr
->cb
;
792 d_printf(2, dev
, "ERX: roq %p - release skb %p (sn %u)\n",
793 roq
, skb_itr
, roq_data_itr
->sn
);
794 __skb_unlink(skb_itr
, &roq
->queue
);
795 i2400m_net_erx(i2400m
, skb_itr
, roq_data_itr
->cs
);
798 d_fnend(2, dev
, "(i2400m %p roq %p) = void\n", i2400m
, roq
);
805 * @i2400m: device descriptor
807 * @skb: containing the packet data
808 * @fbn: First block number of the packet in @skb
809 * @lbn: Last block number of the packet in @skb
811 * The hardware is asking the driver to queue a packet for later
812 * delivery to the networking stack.
815 void i2400m_roq_queue(struct i2400m
*i2400m
, struct i2400m_roq
*roq
,
816 struct sk_buff
* skb
, unsigned lbn
)
818 struct device
*dev
= i2400m_dev(i2400m
);
821 d_fnstart(2, dev
, "(i2400m %p roq %p skb %p lbn %u) = void\n",
822 i2400m
, roq
, skb
, lbn
);
823 len
= skb_queue_len(&roq
->queue
);
824 nsn
= __i2400m_roq_nsn(roq
, lbn
);
825 if (unlikely(nsn
>= 1024)) {
826 dev_err(dev
, "SW BUG? queue nsn %d (lbn %u ws %u)\n",
828 i2400m_roq_log_dump(i2400m
, roq
);
829 i2400m_reset(i2400m
, I2400M_RT_WARM
);
831 __i2400m_roq_queue(i2400m
, roq
, skb
, lbn
, nsn
);
832 i2400m_roq_log_add(i2400m
, roq
, I2400M_RO_TYPE_PACKET
,
833 roq
->ws
, len
, lbn
, nsn
, ~0);
835 d_fnend(2, dev
, "(i2400m %p roq %p skb %p lbn %u) = void\n",
836 i2400m
, roq
, skb
, lbn
);
841 * Update the window start in a reorder queue and deliver all skbs
842 * with a lower window start
844 * @i2400m: device descriptor
845 * @roq: Reorder queue
846 * @sn: New sequence number
849 void i2400m_roq_update_ws(struct i2400m
*i2400m
, struct i2400m_roq
*roq
,
852 struct device
*dev
= i2400m_dev(i2400m
);
853 unsigned old_ws
, nsn
, len
;
855 d_fnstart(2, dev
, "(i2400m %p roq %p sn %u)\n", i2400m
, roq
, sn
);
857 len
= skb_queue_len(&roq
->queue
);
858 nsn
= __i2400m_roq_update_ws(i2400m
, roq
, sn
);
859 i2400m_roq_log_add(i2400m
, roq
, I2400M_RO_TYPE_WS
,
860 old_ws
, len
, sn
, nsn
, roq
->ws
);
861 d_fnstart(2, dev
, "(i2400m %p roq %p sn %u) = void\n", i2400m
, roq
, sn
);
866 * Queue a packet and update the window start
868 * @i2400m: device descriptor
870 * @skb: containing the packet data
871 * @fbn: First block number of the packet in @skb
872 * @sn: Last block number of the packet in @skb
874 * Note that unlike i2400m_roq_update_ws(), which sets the new window
875 * start to @sn, in here we'll set it to @sn + 1.
878 void i2400m_roq_queue_update_ws(struct i2400m
*i2400m
, struct i2400m_roq
*roq
,
879 struct sk_buff
* skb
, unsigned sn
)
881 struct device
*dev
= i2400m_dev(i2400m
);
882 unsigned nsn
, old_ws
, len
;
884 d_fnstart(2, dev
, "(i2400m %p roq %p skb %p sn %u)\n",
885 i2400m
, roq
, skb
, sn
);
886 len
= skb_queue_len(&roq
->queue
);
887 nsn
= __i2400m_roq_nsn(roq
, sn
);
889 if (unlikely(nsn
>= 1024)) {
890 dev_err(dev
, "SW BUG? queue_update_ws nsn %u (sn %u ws %u)\n",
892 i2400m_roq_log_dump(i2400m
, roq
);
893 i2400m_reset(i2400m
, I2400M_RT_WARM
);
895 /* if the queue is empty, don't bother as we'd queue
896 * it and inmediately unqueue it -- just deliver it */
898 struct i2400m_roq_data
*roq_data
;
899 roq_data
= (struct i2400m_roq_data
*) &skb
->cb
;
900 i2400m_net_erx(i2400m
, skb
, roq_data
->cs
);
903 __i2400m_roq_queue(i2400m
, roq
, skb
, sn
, nsn
);
904 __i2400m_roq_update_ws(i2400m
, roq
, sn
+ 1);
905 i2400m_roq_log_add(i2400m
, roq
, I2400M_RO_TYPE_PACKET_WS
,
906 old_ws
, len
, sn
, nsn
, roq
->ws
);
908 d_fnend(2, dev
, "(i2400m %p roq %p skb %p sn %u) = void\n",
909 i2400m
, roq
, skb
, sn
);
914 * Receive and send up an extended data packet
916 * @i2400m: device descriptor
917 * @skb_rx: skb that contains the extended data packet
918 * @single_last: 1 if the payload is the only one or the last one of
920 * @payload: pointer to the packet's data inside the skb
921 * @size: size of the payload
923 * Starting in v1.4 of the i2400m's firmware, the device can send data
924 * packets to the host in an extended format that; this incudes a 16
925 * byte header (struct i2400m_pl_edata_hdr). Using this header's space
926 * we can fake ethernet headers for ethernet device emulation without
927 * having to copy packets around.
929 * This function handles said path.
932 * Receive and send up an extended data packet that requires no reordering
934 * @i2400m: device descriptor
935 * @skb_rx: skb that contains the extended data packet
936 * @single_last: 1 if the payload is the only one or the last one of
938 * @payload: pointer to the packet's data (past the actual extended
939 * data payload header).
940 * @size: size of the payload
942 * Pass over to the networking stack a data packet that might have
943 * reordering requirements.
945 * This needs to the decide if the skb in which the packet is
946 * contained can be reused or if it needs to be cloned. Then it has to
947 * be trimmed in the edges so that the beginning is the space for eth
948 * header and then pass it to i2400m_net_erx() for the stack
950 * Assumes the caller has verified the sanity of the payload (size,
954 void i2400m_rx_edata(struct i2400m
*i2400m
, struct sk_buff
*skb_rx
,
955 unsigned single_last
, const void *payload
, size_t size
)
957 struct device
*dev
= i2400m_dev(i2400m
);
958 const struct i2400m_pl_edata_hdr
*hdr
= payload
;
959 struct net_device
*net_dev
= i2400m
->wimax_dev
.net_dev
;
963 unsigned ro_needed
, ro_type
, ro_cin
, ro_sn
;
964 struct i2400m_roq
*roq
;
965 struct i2400m_roq_data
*roq_data
;
967 BUILD_BUG_ON(ETH_HLEN
> sizeof(*hdr
));
969 d_fnstart(2, dev
, "(i2400m %p skb_rx %p single %u payload %p "
970 "size %zu)\n", i2400m
, skb_rx
, single_last
, payload
, size
);
971 if (size
< sizeof(*hdr
)) {
972 dev_err(dev
, "ERX: HW BUG? message with short header (%zu "
973 "vs %zu bytes expected)\n", size
, sizeof(*hdr
));
978 skb
= skb_get(skb_rx
);
979 d_printf(3, dev
, "ERX: skb %p reusing\n", skb
);
981 skb
= skb_clone(skb_rx
, GFP_KERNEL
);
983 dev_err(dev
, "ERX: no memory to clone skb\n");
984 net_dev
->stats
.rx_dropped
++;
985 goto error_skb_clone
;
987 d_printf(3, dev
, "ERX: skb %p cloned from %p\n", skb
, skb_rx
);
989 /* now we have to pull and trim so that the skb points to the
990 * beginning of the IP packet; the netdev part will add the
991 * ethernet header as needed - we know there is enough space
992 * because we checked in i2400m_rx_edata(). */
993 skb_pull(skb
, payload
+ sizeof(*hdr
) - (void *) skb
->data
);
994 skb_trim(skb
, (void *) skb_end_pointer(skb
) - payload
- sizeof(*hdr
));
996 reorder
= le32_to_cpu(hdr
->reorder
);
997 ro_needed
= reorder
& I2400M_RO_NEEDED
;
1000 ro_type
= (reorder
>> I2400M_RO_TYPE_SHIFT
) & I2400M_RO_TYPE
;
1001 ro_cin
= (reorder
>> I2400M_RO_CIN_SHIFT
) & I2400M_RO_CIN
;
1002 ro_sn
= (reorder
>> I2400M_RO_SN_SHIFT
) & I2400M_RO_SN
;
1004 roq
= &i2400m
->rx_roq
[ro_cin
];
1005 roq_data
= (struct i2400m_roq_data
*) &skb
->cb
;
1006 roq_data
->sn
= ro_sn
;
1008 d_printf(2, dev
, "ERX: reorder needed: "
1009 "type %u cin %u [ws %u] sn %u/%u len %zuB\n",
1010 ro_type
, ro_cin
, roq
->ws
, ro_sn
,
1011 __i2400m_roq_nsn(roq
, ro_sn
), size
);
1012 d_dump(2, dev
, payload
, size
);
1014 case I2400M_RO_TYPE_RESET
:
1015 i2400m_roq_reset(i2400m
, roq
);
1016 kfree_skb(skb
); /* no data here */
1018 case I2400M_RO_TYPE_PACKET
:
1019 i2400m_roq_queue(i2400m
, roq
, skb
, ro_sn
);
1021 case I2400M_RO_TYPE_WS
:
1022 i2400m_roq_update_ws(i2400m
, roq
, ro_sn
);
1023 kfree_skb(skb
); /* no data here */
1025 case I2400M_RO_TYPE_PACKET_WS
:
1026 i2400m_roq_queue_update_ws(i2400m
, roq
, skb
, ro_sn
);
1029 dev_err(dev
, "HW BUG? unknown reorder type %u\n", ro_type
);
1033 i2400m_net_erx(i2400m
, skb
, cs
);
1036 d_fnend(2, dev
, "(i2400m %p skb_rx %p single %u payload %p "
1037 "size %zu) = void\n", i2400m
, skb_rx
, single_last
, payload
, size
);
1042 * Act on a received payload
1044 * @i2400m: device instance
1045 * @skb_rx: skb where the transaction was received
1046 * @single_last: 1 this is the only payload or the last one (so the
1047 * skb can be reused instead of cloned).
1048 * @pld: payload descriptor
1049 * @payload: payload data
1051 * Upon reception of a payload, look at its guts in the payload
1052 * descriptor and decide what to do with it. If it is a single payload
1053 * skb or if the last skb is a data packet, the skb will be referenced
1054 * and modified (so it doesn't have to be cloned).
1057 void i2400m_rx_payload(struct i2400m
*i2400m
, struct sk_buff
*skb_rx
,
1058 unsigned single_last
, const struct i2400m_pld
*pld
,
1059 const void *payload
)
1061 struct device
*dev
= i2400m_dev(i2400m
);
1062 size_t pl_size
= i2400m_pld_size(pld
);
1063 enum i2400m_pt pl_type
= i2400m_pld_type(pld
);
1065 d_printf(7, dev
, "RX: received payload type %u, %zu bytes\n",
1067 d_dump(8, dev
, payload
, pl_size
);
1070 case I2400M_PT_DATA
:
1071 d_printf(3, dev
, "RX: data payload %zu bytes\n", pl_size
);
1072 i2400m_net_rx(i2400m
, skb_rx
, single_last
, payload
, pl_size
);
1074 case I2400M_PT_CTRL
:
1075 i2400m_rx_ctl(i2400m
, skb_rx
, payload
, pl_size
);
1077 case I2400M_PT_TRACE
:
1078 i2400m_rx_trace(i2400m
, payload
, pl_size
);
1080 case I2400M_PT_EDATA
:
1081 d_printf(3, dev
, "ERX: data payload %zu bytes\n", pl_size
);
1082 i2400m_rx_edata(i2400m
, skb_rx
, single_last
, payload
, pl_size
);
1084 default: /* Anything else shouldn't come to the host */
1085 if (printk_ratelimit())
1086 dev_err(dev
, "RX: HW BUG? unexpected payload type %u\n",
1093 * Check a received transaction's message header
1095 * @i2400m: device descriptor
1096 * @msg_hdr: message header
1097 * @buf_size: size of the received buffer
1099 * Check that the declarations done by a RX buffer message header are
1100 * sane and consistent with the amount of data that was received.
1103 int i2400m_rx_msg_hdr_check(struct i2400m
*i2400m
,
1104 const struct i2400m_msg_hdr
*msg_hdr
,
1108 struct device
*dev
= i2400m_dev(i2400m
);
1109 if (buf_size
< sizeof(*msg_hdr
)) {
1110 dev_err(dev
, "RX: HW BUG? message with short header (%zu "
1111 "vs %zu bytes expected)\n", buf_size
, sizeof(*msg_hdr
));
1114 if (msg_hdr
->barker
!= cpu_to_le32(I2400M_D2H_MSG_BARKER
)) {
1115 dev_err(dev
, "RX: HW BUG? message received with unknown "
1116 "barker 0x%08x (buf_size %zu bytes)\n",
1117 le32_to_cpu(msg_hdr
->barker
), buf_size
);
1120 if (msg_hdr
->num_pls
== 0) {
1121 dev_err(dev
, "RX: HW BUG? zero payload packets in message\n");
1124 if (le16_to_cpu(msg_hdr
->num_pls
) > I2400M_MAX_PLS_IN_MSG
) {
1125 dev_err(dev
, "RX: HW BUG? message contains more payload "
1126 "than maximum; ignoring.\n");
1136 * Check a payload descriptor against the received data
1138 * @i2400m: device descriptor
1139 * @pld: payload descriptor
1140 * @pl_itr: offset (in bytes) in the received buffer the payload is
1142 * @buf_size: size of the received buffer
1144 * Given a payload descriptor (part of a RX buffer), check it is sane
1145 * and that the data it declares fits in the buffer.
1148 int i2400m_rx_pl_descr_check(struct i2400m
*i2400m
,
1149 const struct i2400m_pld
*pld
,
1150 size_t pl_itr
, size_t buf_size
)
1153 struct device
*dev
= i2400m_dev(i2400m
);
1154 size_t pl_size
= i2400m_pld_size(pld
);
1155 enum i2400m_pt pl_type
= i2400m_pld_type(pld
);
1157 if (pl_size
> i2400m
->bus_pl_size_max
) {
1158 dev_err(dev
, "RX: HW BUG? payload @%zu: size %zu is "
1159 "bigger than maximum %zu; ignoring message\n",
1160 pl_itr
, pl_size
, i2400m
->bus_pl_size_max
);
1163 if (pl_itr
+ pl_size
> buf_size
) { /* enough? */
1164 dev_err(dev
, "RX: HW BUG? payload @%zu: size %zu "
1165 "goes beyond the received buffer "
1166 "size (%zu bytes); ignoring message\n",
1167 pl_itr
, pl_size
, buf_size
);
1170 if (pl_type
>= I2400M_PT_ILLEGAL
) {
1171 dev_err(dev
, "RX: HW BUG? illegal payload type %u; "
1172 "ignoring message\n", pl_type
);
1182 * i2400m_rx - Receive a buffer of data from the device
1184 * @i2400m: device descriptor
1185 * @skb: skbuff where the data has been received
1187 * Parse in a buffer of data that contains an RX message sent from the
1188 * device. See the file header for the format. Run all checks on the
1189 * buffer header, then run over each payload's descriptors, verify
1190 * their consistency and act on each payload's contents. If
1191 * everything is successful, update the device's statistics.
1193 * Note: You need to set the skb to contain only the length of the
1194 * received buffer; for that, use skb_trim(skb, RECEIVED_SIZE).
1198 * 0 if ok, < 0 errno on error
1200 * If ok, this function owns now the skb and the caller DOESN'T have
1201 * to run kfree_skb() on it. However, on error, the caller still owns
1202 * the skb and it is responsible for releasing it.
1204 int i2400m_rx(struct i2400m
*i2400m
, struct sk_buff
*skb
)
1207 struct device
*dev
= i2400m_dev(i2400m
);
1208 const struct i2400m_msg_hdr
*msg_hdr
;
1209 size_t pl_itr
, pl_size
, skb_len
;
1210 unsigned long flags
;
1211 unsigned num_pls
, single_last
;
1214 d_fnstart(4, dev
, "(i2400m %p skb %p [size %zu])\n",
1215 i2400m
, skb
, skb_len
);
1217 msg_hdr
= (void *) skb
->data
;
1218 result
= i2400m_rx_msg_hdr_check(i2400m
, msg_hdr
, skb
->len
);
1220 goto error_msg_hdr_check
;
1222 num_pls
= le16_to_cpu(msg_hdr
->num_pls
);
1223 pl_itr
= sizeof(*msg_hdr
) + /* Check payload descriptor(s) */
1224 num_pls
* sizeof(msg_hdr
->pld
[0]);
1225 pl_itr
= ALIGN(pl_itr
, I2400M_PL_ALIGN
);
1226 if (pl_itr
> skb
->len
) { /* got all the payload descriptors? */
1227 dev_err(dev
, "RX: HW BUG? message too short (%u bytes) for "
1228 "%u payload descriptors (%zu each, total %zu)\n",
1229 skb
->len
, num_pls
, sizeof(msg_hdr
->pld
[0]), pl_itr
);
1230 goto error_pl_descr_short
;
1232 /* Walk each payload payload--check we really got it */
1233 for (i
= 0; i
< num_pls
; i
++) {
1234 /* work around old gcc warnings */
1235 pl_size
= i2400m_pld_size(&msg_hdr
->pld
[i
]);
1236 result
= i2400m_rx_pl_descr_check(i2400m
, &msg_hdr
->pld
[i
],
1239 goto error_pl_descr_check
;
1240 single_last
= num_pls
== 1 || i
== num_pls
- 1;
1241 i2400m_rx_payload(i2400m
, skb
, single_last
, &msg_hdr
->pld
[i
],
1242 skb
->data
+ pl_itr
);
1243 pl_itr
+= ALIGN(pl_size
, I2400M_PL_ALIGN
);
1244 cond_resched(); /* Don't monopolize */
1247 /* Update device statistics */
1248 spin_lock_irqsave(&i2400m
->rx_lock
, flags
);
1249 i2400m
->rx_pl_num
+= i
;
1250 if (i
> i2400m
->rx_pl_max
)
1251 i2400m
->rx_pl_max
= i
;
1252 if (i
< i2400m
->rx_pl_min
)
1253 i2400m
->rx_pl_min
= i
;
1255 i2400m
->rx_size_acc
+= skb
->len
;
1256 if (skb
->len
< i2400m
->rx_size_min
)
1257 i2400m
->rx_size_min
= skb
->len
;
1258 if (skb
->len
> i2400m
->rx_size_max
)
1259 i2400m
->rx_size_max
= skb
->len
;
1260 spin_unlock_irqrestore(&i2400m
->rx_lock
, flags
);
1261 error_pl_descr_check
:
1262 error_pl_descr_short
:
1263 error_msg_hdr_check
:
1264 d_fnend(4, dev
, "(i2400m %p skb %p [size %zu]) = %d\n",
1265 i2400m
, skb
, skb_len
, result
);
1268 EXPORT_SYMBOL_GPL(i2400m_rx
);
1271 void i2400m_unknown_barker(struct i2400m
*i2400m
,
1272 const void *buf
, size_t size
)
1274 struct device
*dev
= i2400m_dev(i2400m
);
1276 const __le32
*barker
= buf
;
1277 dev_err(dev
, "RX: HW BUG? unknown barker %08x, "
1278 "dropping %zu bytes\n", le32_to_cpu(*barker
), size
);
1279 snprintf(prefix
, sizeof(prefix
), "%s %s: ",
1280 dev_driver_string(dev
), dev_name(dev
));
1282 print_hex_dump(KERN_ERR
, prefix
, DUMP_PREFIX_OFFSET
,
1284 printk(KERN_ERR
"%s... (only first 64 bytes "
1285 "dumped)\n", prefix
);
1287 print_hex_dump(KERN_ERR
, prefix
, DUMP_PREFIX_OFFSET
,
1288 8, 4, buf
, size
, 0);
1290 EXPORT_SYMBOL(i2400m_unknown_barker
);
1294 * Initialize the RX queue and infrastructure
1296 * This sets up all the RX reordering infrastructures, which will not
1297 * be used if reordering is not enabled or if the firmware does not
1298 * support it. The device is told to do reordering in
1299 * i2400m_dev_initialize(), where it also looks at the value of the
1300 * i2400m->rx_reorder switch before taking a decission.
1302 * Note we allocate the roq queues in one chunk and the actual logging
1303 * support for it (logging) in another one and then we setup the
1304 * pointers from the first to the last.
1306 int i2400m_rx_setup(struct i2400m
*i2400m
)
1309 struct device
*dev
= i2400m_dev(i2400m
);
1311 i2400m
->rx_reorder
= i2400m_rx_reorder_disabled
? 0 : 1;
1312 if (i2400m
->rx_reorder
) {
1315 struct i2400m_roq_log
*rd
;
1319 size
= sizeof(i2400m
->rx_roq
[0]) * (I2400M_RO_CIN
+ 1);
1320 i2400m
->rx_roq
= kzalloc(size
, GFP_KERNEL
);
1321 if (i2400m
->rx_roq
== NULL
) {
1322 dev_err(dev
, "RX: cannot allocate %zu bytes for "
1323 "reorder queues\n", size
);
1324 goto error_roq_alloc
;
1327 size
= sizeof(*i2400m
->rx_roq
[0].log
) * (I2400M_RO_CIN
+ 1);
1328 rd
= kzalloc(size
, GFP_KERNEL
);
1330 dev_err(dev
, "RX: cannot allocate %zu bytes for "
1331 "reorder queues log areas\n", size
);
1333 goto error_roq_log_alloc
;
1336 for(itr
= 0; itr
< I2400M_RO_CIN
+ 1; itr
++) {
1337 __i2400m_roq_init(&i2400m
->rx_roq
[itr
]);
1338 i2400m
->rx_roq
[itr
].log
= &rd
[itr
];
1343 error_roq_log_alloc
:
1344 kfree(i2400m
->rx_roq
);
1350 /* Tear down the RX queue and infrastructure */
1351 void i2400m_rx_release(struct i2400m
*i2400m
)
1353 if (i2400m
->rx_reorder
) {
1355 for(itr
= 0; itr
< I2400M_RO_CIN
+ 1; itr
++)
1356 __skb_queue_purge(&i2400m
->rx_roq
[itr
].queue
);
1357 kfree(i2400m
->rx_roq
[0].log
);
1358 kfree(i2400m
->rx_roq
);
1360 /* at this point, nothing can be received... */
1361 i2400m_report_hook_flush(i2400m
);