65 |
65 |
return 10000 * n_errors / n_bits_total;
|
66 |
66 |
}
|
67 |
67 |
|
|
68 |
|
|
69 |
static void reset_ul_bursts(struct l1sched_chan_state *chan_state)
|
|
70 |
{
|
|
71 |
if (chan_state->ul_bursts)
|
|
72 |
memset(chan_state->ul_bursts, 0, 464);
|
|
73 |
chan_state->ul_mask = 0x0;
|
|
74 |
chan_state->rssi_sum = 0;
|
|
75 |
chan_state->rssi_num = 0;
|
|
76 |
chan_state->toa256_sum = 0;
|
|
77 |
chan_state->toa_num = 0;
|
|
78 |
}
|
|
79 |
|
|
80 |
static int _submit_ph_data_ind_with_ul_meas_res(struct l1sched_trx *l1t, uint8_t tn,
|
|
81 |
uint32_t fn, enum trx_chan_type chan,
|
|
82 |
struct l1sched_chan_state *chan_state)
|
|
83 |
{
|
|
84 |
uint8_t l2[GSM_MACBLOCK_LEN], l2_len;
|
|
85 |
int n_errors, n_bits_total;
|
|
86 |
uint16_t ber10k;
|
|
87 |
float rssi;
|
|
88 |
int16_t toa256;
|
|
89 |
int rc;
|
|
90 |
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);
|
|
91 |
|
|
92 |
/* empty mask -> empty buffer, no need to decode buffer (buffer may not even be allocated) */
|
|
93 |
if (chan_state->ul_mask == 0x0) {
|
|
94 |
l1if_process_meas_res(l1t->trx, tn, fn, trx_chan_desc[chan].chan_nr | tn,
|
|
95 |
456, 456, -110, 0);
|
|
96 |
ber10k = compute_ber10k(0, 456);
|
|
97 |
return _sched_compose_ph_data_ind(l1t, tn, 0, chan, NULL, 0,
|
|
98 |
-110, 0, 0, ber10k,
|
|
99 |
PRES_INFO_INVALID);
|
|
100 |
}
|
|
101 |
|
|
102 |
/* Once processed, erase mask so they are not used again, also invalidating ul_first_fn */
|
|
103 |
chan_state->ul_mask = 0x0;
|
|
104 |
rssi = chan_state->rssi_sum / chan_state->rssi_num;
|
|
105 |
toa256 = chan_state->toa256_sum / chan_state->toa_num;
|
|
106 |
/* decode */
|
|
107 |
rc = gsm0503_xcch_decode(l2, chan_state->ul_bursts, &n_errors, &n_bits_total);
|
|
108 |
if (rc) {
|
|
109 |
LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn, "Received bad data (%u/%u)\n",
|
|
110 |
chan_state->ul_first_fn, chan_state->ul_first_fn % l1ts->mf_period);
|
|
111 |
l2_len = 0;
|
|
112 |
} else
|
|
113 |
l2_len = GSM_MACBLOCK_LEN;
|
|
114 |
|
|
115 |
/* Send uplink measurement information to L2 */
|
|
116 |
l1if_process_meas_res(l1t->trx, tn, chan_state->ul_first_fn, trx_chan_desc[chan].chan_nr | tn,
|
|
117 |
n_errors, n_bits_total, rssi, toa256);
|
|
118 |
ber10k = compute_ber10k(n_bits_total, n_errors);
|
|
119 |
return _sched_compose_ph_data_ind(l1t, tn, chan_state->ul_first_fn, chan, l2, l2_len,
|
|
120 |
rssi, 4 * toa256, 0, ber10k, PRES_INFO_UNKNOWN);
|
|
121 |
}
|
|
122 |
|
68 |
123 |
/*
|
69 |
124 |
* TX on downlink
|
70 |
125 |
*/
|
... | ... | |
195 |
250 |
/* count and send BFI */
|
196 |
251 |
LOGP(DMEAS, LOGL_INFO, "PESPIN: tx_data_fn (++) fn=%" PRIu32 " lost_frames=%" PRIu8 " chan_state=%p\n", fn, l1ts->chan_state[chan].lost_frames, &l1ts->chan_state[chan]);
|
197 |
252 |
if (++(l1ts->chan_state[chan].lost_frames) > 1) {
|
198 |
|
/* TODO: Should we pass old TOA here? Otherwise we risk
|
199 |
|
* unnecessary decreasing TA */
|
200 |
253 |
LOGP(DMEAS, LOGL_INFO, "PESPIN: Sending bad MEAS RES\n");
|
201 |
|
/* Send uplink measurement information to L2 */
|
202 |
|
l1if_process_meas_res(l1t->trx, tn, fn, trx_chan_desc[chan].chan_nr | tn,
|
203 |
|
456, 456, -110, 0);
|
204 |
|
/* FIXME: use actual values for BER etc */
|
205 |
|
_sched_compose_ph_data_ind(l1t, tn, 0, chan, NULL, 0,
|
206 |
|
-110, 0, 0, 10000,
|
207 |
|
PRES_INFO_INVALID);
|
|
254 |
_submit_ph_data_ind_with_ul_meas_res(l1t, tn, fn, chan, &l1ts->chan_state[chan]);
|
|
255 |
/* Don't keep re-sending same meas result cached over and over */
|
|
256 |
reset_ul_bursts(&l1ts->chan_state[chan]);
|
208 |
257 |
}
|
209 |
258 |
}
|
210 |
259 |
|
... | ... | |
769 |
818 |
uint8_t *rssi_num = &chan_state->rssi_num;
|
770 |
819 |
int32_t *toa256_sum = &chan_state->toa256_sum;
|
771 |
820 |
uint8_t *toa_num = &chan_state->toa_num;
|
772 |
|
uint8_t l2[GSM_MACBLOCK_LEN], l2_len;
|
773 |
|
int n_errors, n_bits_total;
|
774 |
|
uint16_t ber10k;
|
775 |
|
int rc;
|
776 |
821 |
|
777 |
822 |
/* handle RACH, if handover RACH detection is turned on */
|
778 |
823 |
if (chan_state->ho_rach_detect == 1)
|
... | ... | |
789 |
834 |
|
790 |
835 |
/* clear burst & store frame number of first burst */
|
791 |
836 |
if (bid == 0) {
|
792 |
|
memset(*bursts_p, 0, 464);
|
793 |
|
*mask = 0x0;
|
794 |
837 |
*first_fn = fn;
|
795 |
|
*rssi_sum = 0;
|
796 |
|
*rssi_num = 0;
|
797 |
|
*toa256_sum = 0;
|
798 |
|
*toa_num = 0;
|
|
838 |
reset_ul_bursts(chan_state);
|
799 |
839 |
}
|
800 |
840 |
|
801 |
841 |
/* update mask + RSSI */
|
... | ... | |
831 |
871 |
return 0;
|
832 |
872 |
}
|
833 |
873 |
}
|
834 |
|
*mask = 0x0;
|
835 |
874 |
|
836 |
|
/* decode */
|
837 |
|
rc = gsm0503_xcch_decode(l2, *bursts_p, &n_errors, &n_bits_total);
|
838 |
|
if (rc) {
|
839 |
|
LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn, "Received bad data (%u/%u)\n",
|
840 |
|
*first_fn, (*first_fn) % l1ts->mf_period);
|
841 |
|
l2_len = 0;
|
842 |
|
} else
|
843 |
|
l2_len = GSM_MACBLOCK_LEN;
|
844 |
|
|
845 |
|
/* Send uplink measurement information to L2 */
|
846 |
|
l1if_process_meas_res(l1t->trx, tn, *first_fn, trx_chan_desc[chan].chan_nr | tn,
|
847 |
|
n_errors, n_bits_total, *rssi_sum / *rssi_num, *toa256_sum / *toa_num);
|
848 |
|
ber10k = compute_ber10k(n_bits_total, n_errors);
|
849 |
|
return _sched_compose_ph_data_ind(l1t, tn, *first_fn, chan, l2, l2_len,
|
850 |
|
*rssi_sum / *rssi_num,
|
851 |
|
4 * (*toa256_sum) / *toa_num, 0, ber10k,
|
852 |
|
PRES_INFO_UNKNOWN);
|
|
875 |
return _submit_ph_data_ind_with_ul_meas_res(l1t, tn, fn, chan, chan_state);
|
853 |
876 |
}
|
854 |
877 |
|
855 |
878 |
/*! \brief a single PDTCH burst was received by the PHY, process it */
|