33 #include <linux/export.h>
35 #include <asm/byteorder.h>
101 #ifndef CONFIG_IRDA_DYNAMIC_WINDOW
102 static __u32 irlap_requested_line_capacity(
struct qos_info *qos);
105 static __u32 min_turn_times[] = { 10000, 5000, 1000, 500, 100, 50, 10, 0 };
106 static __u32 baud_rates[] = { 2400, 9600, 19200, 38400, 57600, 115200, 576000,
107 1152000, 4000000, 16000000 };
108 static __u32 data_sizes[] = { 64, 128, 256, 512, 1024, 2048 };
109 static __u32 add_bofs[] = { 48, 24, 12, 5, 3, 2, 1, 0 };
110 static __u32 max_turn_times[] = { 500, 250, 100, 50 };
111 static __u32 link_disc_times[] = { 3, 8, 12, 16, 20, 25, 30, 40 };
113 static __u32 max_line_capacities[10][4] = {
120 { 4800, 2400, 960, 480 },
121 { 28800, 11520, 5760, 2880 },
122 { 57600, 28800, 11520, 5760 },
123 { 200000, 100000, 40000, 20000 },
124 { 800000, 400000, 160000, 80000 },
150 { pi_minor_call_table_type_0, 9 },
151 { pi_minor_call_table_type_1, 7 },
154 static pi_param_info_t irlap_param_info = { pi_major_call_table, 2, 0x7f, 7 };
171 for (i=0; i <
size; i++)
172 if (array[i] == value)
205 IRDA_WARNING(
"%s(), Detected buggy peer, adjust null PV to 0x1!\n",
231 for (i=0; i <
size; i++) {
236 if (array[i] >= value)
251 static inline int value_highest_bit(
__u32 value,
__u32 *array,
int size,
__u16 *field)
257 for (i=0; i <
size; i++) {
259 if (array[i] <= value)
342 static void irlap_adjust_qos_settings(
struct qos_info *qos)
356 IRDA_WARNING(
"%s(), Detected buggy peer, adjust mtt to %dus!\n",
374 "%s(), adjusting max turn time from %d to 500 ms\n",
387 #ifdef CONFIG_IRDA_DYNAMIC_WINDOW
390 IRDA_DEBUG(2,
"%s(), reducing data size to %d\n",
394 while (irlap_requested_line_capacity(qos) > line_capacity) {
400 IRDA_DEBUG(2,
"%s(), reducing window size to %d\n",
402 }
else if (index > 1) {
404 IRDA_DEBUG(2,
"%s(), reducing data size to %d\n",
443 irlap_adjust_qos_settings(&self->qos_tx);
445 IRDA_DEBUG(2,
"Setting BAUD_RATE to %d bps.\n",
446 self->qos_tx.baud_rate.value);
447 IRDA_DEBUG(2,
"Setting DATA_SIZE to %d bytes\n",
448 self->qos_tx.data_size.value);
450 self->qos_tx.window_size.value);
452 self->qos_tx.additional_bofs.value);
453 IRDA_DEBUG(2,
"Setting MAX_TURN_TIME to %d ms.\n",
454 self->qos_tx.max_turn_time.value);
455 IRDA_DEBUG(2,
"Setting MIN_TURN_TIME to %d usecs.\n",
456 self->qos_tx.min_turn_time.value);
457 IRDA_DEBUG(2,
"Setting LINK_DISC to %d secs.\n",
458 self->qos_tx.link_disc_time.value);
475 skb_tailroom(skb), &irlap_param_info);
482 skb_tailroom(skb), &irlap_param_info);
489 skb_tailroom(skb), &irlap_param_info);
496 skb_tailroom(skb), &irlap_param_info);
503 skb_tailroom(skb), &irlap_param_info);
510 skb_tailroom(skb), &irlap_param_info);
517 skb_tailroom(skb), &irlap_param_info);
541 param->
pv.
i =
self->qos_rx.baud_rate.bits;
543 __func__, param->
pv.
i);
550 final = (
__u16) param->
pv.
i & self->qos_rx.baud_rate.bits;
552 IRDA_DEBUG(2,
"Final BAUD_RATE: 0x%04x\n",
final);
553 self->qos_tx.baud_rate.bits =
final;
554 self->qos_rx.baud_rate.bits =
final;
566 static int irlap_param_link_disconnect(
void *instance,
irda_param_t *param,
577 param->
pv.
i =
self->qos_rx.link_disc_time.bits;
584 final = (
__u8) param->
pv.
i & self->qos_rx.link_disc_time.bits;
586 IRDA_DEBUG(2,
"Final LINK_DISC: %02x\n",
final);
587 self->qos_tx.link_disc_time.bits =
final;
588 self->qos_rx.link_disc_time.bits =
final;
600 static int irlap_param_max_turn_time(
void *instance,
irda_param_t *param,
609 param->
pv.
i =
self->qos_rx.max_turn_time.bits;
611 self->qos_tx.max_turn_time.bits = (
__u8) param->
pv.
i;
623 static int irlap_param_data_size(
void *instance,
irda_param_t *param,
int get)
631 param->
pv.
i =
self->qos_rx.data_size.bits;
633 self->qos_tx.data_size.bits = (
__u8) param->
pv.
i;
645 static int irlap_param_window_size(
void *instance,
irda_param_t *param,
654 param->
pv.
i =
self->qos_rx.window_size.bits;
656 self->qos_tx.window_size.bits = (
__u8) param->
pv.
i;
667 static int irlap_param_additional_bofs(
void *instance,
irda_param_t *param,
int get)
675 param->
pv.
i =
self->qos_rx.additional_bofs.bits;
677 self->qos_tx.additional_bofs.bits = (
__u8) param->
pv.
i;
688 static int irlap_param_min_turn_time(
void *instance,
irda_param_t *param,
697 param->
pv.
i =
self->qos_rx.min_turn_time.bits;
699 self->qos_tx.min_turn_time.bits = (
__u8) param->
pv.
i;
715 IRDA_DEBUG(2,
"%s(), speed=%d, max_turn_time=%d\n",
716 __func__, speed, max_turn_time);
718 i = value_index(speed, baud_rates, 10);
719 j = value_index(max_turn_time, max_turn_times, 4);
724 line_capacity = max_line_capacities[
i][
j];
726 IRDA_DEBUG(2,
"%s(), line capacity=%d bytes\n",
727 __func__, line_capacity);
732 #ifndef CONFIG_IRDA_DYNAMIC_WINDOW
733 static __u32 irlap_requested_line_capacity(
struct qos_info *qos)
742 IRDA_DEBUG(2,
"%s(), requested line capacity=%d\n",
743 __func__, line_capacity);