Change in osmo-msc[master]: add full SDP codec information to the MNCC socket

2019-11-27 Thread neels
Hello pespin, Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmo-msc/+/15953

to look at the new patch set (#6).

Change subject: add full SDP codec information to the MNCC socket
..

add full SDP codec information to the MNCC socket

This way osmo-msc can benefit from the complete codec information received via
SIP, which was so far terminated at osmo-sip-connector. osmo-sip-connector
could/should have translated the received SDP to MNCC bearer_cap, but this was
never implemented properly. Since osmo-msc already handles SDP towards the MGW,
it makes most sense to pass SDP to osmo-msc transparently.

To be able to send a valid RTP IP:port in the SDP upon the first MNCC_SETUP_IND
going out, move the CN side CRCX to the very start of establishing a voice
call. As a result, first create MGW conns for both RAN and CN before starting.

The voice_call_full.msc chart shows the change in message sequence for MO and
MT voice calls.

Implement cc_sdp.c, which accumulates codec information from various sources
(MS, BSS, Assignment, remote call leg) and provides filtering to get the
available set of codecs at any point in time.

Implement codec_sdp_cc_t9n.c, to translate between SDP and the various
libosmo-mgcp-client, CC and BSSMAP representations of codecs:
- Speech Version,
- Permitted Speech,
- Speech Codec Type,
- default Payload Type numbers,
- enum mgcp_codecs,
- FR/HR compatibility
- SDP audio codec names,
- various AMR configurations.
A codec_map lists these relations in one large data record.
Various functions provide conversions by traversing this map.

Add trans->cc.mnccc_release_sent: so far, avoiding to send an MNCC release
during trans_free() was done by setting the callref = 0. But that also skips CC
Release. On codec mismatch, we send a specific MNCC error code but still want a
normal CC Release: hence send the MNCC message, set mnccc_release_sent = true
and do normal CC Release in trans_free().
(A better way to do this would be to adopt the mncc_call FSM from inter-MSC
handover also for local voice calls, but that is out of scope for now. I want
to try that soon, as time permits.)

Change-Id: I8c3b2de53ffae4ec3a66b9dabf308c290a2c999f
---
M doc/sequence_charts/voice_call_full.msc
M include/osmocom/msc/Makefile.am
M include/osmocom/msc/call_leg.h
A include/osmocom/msc/cc_sdp.h
A include/osmocom/msc/codec_sdp_cc_t9n.h
M include/osmocom/msc/gsm_04_08.h
M include/osmocom/msc/msc_a.h
M include/osmocom/msc/msc_ho.h
M include/osmocom/msc/rtp_stream.h
M include/osmocom/msc/sdp_msg.h
M include/osmocom/msc/transaction.h
M src/libmsc/Makefile.am
M src/libmsc/call_leg.c
A src/libmsc/cc_sdp.c
A src/libmsc/codec_sdp_cc_t9n.c
M src/libmsc/gsm_04_08_cc.c
M src/libmsc/mncc_call.c
M src/libmsc/msc_a.c
M src/libmsc/msc_ho.c
M src/libmsc/msc_t.c
M src/libmsc/rtp_stream.c
M src/libmsc/sdp_msg.c
M tests/msc_vlr/msc_vlr_test_call.c
M tests/msc_vlr/msc_vlr_test_call.err
M tests/msc_vlr/msc_vlr_tests.c
M tests/msc_vlr/msc_vlr_tests.h
M tests/sdp_msg/sdp_msg_test.ok
27 files changed, 5,489 insertions(+), 445 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/53/15953/6
--
To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/15953
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: I8c3b2de53ffae4ec3a66b9dabf308c290a2c999f
Gerrit-Change-Number: 15953
Gerrit-PatchSet: 6
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: neels 
Gerrit-Reviewer: pespin 
Gerrit-MessageType: newpatchset


Change in osmo-msc[master]: msc_a CC: add some basic sanity tests

2019-11-27 Thread neels
neels has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-msc/+/16303 )


Change subject: msc_a CC: add some basic sanity tests
..

msc_a CC: add some basic sanity tests

Change-Id: I9d7d7d4073282abc6c02a6a297c807dc70c5154c
---
M src/libmsc/msc_a.c
1 file changed, 10 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/03/16303/1

diff --git a/src/libmsc/msc_a.c b/src/libmsc/msc_a.c
index a4048f4..bc5b7ea 100644
--- a/src/libmsc/msc_a.c
+++ b/src/libmsc/msc_a.c
@@ -518,6 +518,12 @@
struct gsm_trans *cc_trans = msc_a->cc.active_trans;
struct gsm0808_channel_type channel_type;

+   if (!cc_trans) {
+   LOG_MSC_A(msc_a, LOGL_ERROR, "No CC transaction active\n");
+   call_leg_release(msc_a->cc.call_leg);
+   return;
+   }
+
/* Once a CI is known, we could also CRCX the CN side of the MGW 
endpoint, but it makes sense to wait for the
 * codec to be determined by the Assignment Complete message, first. */

@@ -627,6 +633,10 @@
LOG_MSC_A(msc_a, LOGL_ERROR, "Invalid data for %s\n", 
osmo_fsm_event_name(fi->fsm, event));
return;
}
+   if (!msc_a->cc.call_leg) {
+   LOG_MSC_A(msc_a, LOGL_ERROR, "No call leg active\n");
+   return;
+   }
if (!osmo_sockaddr_str_is_nonzero(&rtps->local)) {
LOG_MSC_A(msc_a, LOGL_ERROR, "Invalid RTP address 
received from MGW: " OSMO_SOCKADDR_STR_FMT "\n",
 OSMO_SOCKADDR_STR_FMT_ARGS(&rtps->local));

--
To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/16303
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: I9d7d7d4073282abc6c02a6a297c807dc70c5154c
Gerrit-Change-Number: 16303
Gerrit-PatchSet: 1
Gerrit-Owner: neels 
Gerrit-MessageType: newchange


Change in osmo-msc[master]: fail on invalid RTP address from MGW

2019-11-27 Thread neels
neels has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-msc/+/16302 )


Change subject: fail on invalid RTP address from MGW
..

fail on invalid RTP address from MGW

When the CRCX OK returns an invalid RTP address, abort the call; fixes
MSC_Tests.TC_invalid_mgcp_crash.

The original crash happened when adding this error handling without this commit
I08c03946605aa12e0a5ce8b3c773704ef5327a7a ("fsm: use deferred deallocation" for
osmo-mgw I7df2e9202b04e7ca7366bb0a8ec53cf3bb14faf3 "fix use-after-free: require
new fsm deferred dealloc, check for term"). With this error handling added,
even though avoiding a crash, the test does not pass yet, because instead of
rejecting the call, it currently composes an Assignment Command without a
Transport Layer Address. Fix that.

Change-Id: I00c3b5ff74c05bcc2b7c39375c33419916a57193
---
M src/libmsc/msc_a.c
1 file changed, 6 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/02/16302/1

diff --git a/src/libmsc/msc_a.c b/src/libmsc/msc_a.c
index 0b07fbc..a4048f4 100644
--- a/src/libmsc/msc_a.c
+++ b/src/libmsc/msc_a.c
@@ -627,6 +627,12 @@
LOG_MSC_A(msc_a, LOGL_ERROR, "Invalid data for %s\n", 
osmo_fsm_event_name(fi->fsm, event));
return;
}
+   if (!osmo_sockaddr_str_is_nonzero(&rtps->local)) {
+   LOG_MSC_A(msc_a, LOGL_ERROR, "Invalid RTP address 
received from MGW: " OSMO_SOCKADDR_STR_FMT "\n",
+OSMO_SOCKADDR_STR_FMT_ARGS(&rtps->local));
+   call_leg_release(msc_a->cc.call_leg);
+   return;
+   }
LOG_MSC_A(msc_a, LOGL_DEBUG,
  "MGW endpoint's RTP address available for the CI %s: 
" OSMO_SOCKADDR_STR_FMT " (osmux=%s:%d)\n",
  rtp_direction_name(rtps->dir), 
OSMO_SOCKADDR_STR_FMT_ARGS(&rtps->local),

--
To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/16302
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: I00c3b5ff74c05bcc2b7c39375c33419916a57193
Gerrit-Change-Number: 16302
Gerrit-PatchSet: 1
Gerrit-Owner: neels 
Gerrit-MessageType: newchange


Change in osmo-ttcn3-hacks[master]: msc: expect only one Paging on GERAN

2019-11-27 Thread neels
neels has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16301 )


Change subject: msc: expect only one Paging on GERAN
..

msc: expect only one Paging on GERAN

After discussion on this thread:
http://lists.osmocom.org/pipermail/openbsc/2019-November/013058.html

Do not expect repeated Paging on GERAN.

Pending clarification on 3G, still expect repeated Paging on Iu, though we are
not 100% certain that this is indeed required.

Fixes MSC_Tests.TC_lu_and_mt_sms_paging_repeated,
but not MSC_Tests_Iu.TC_iu_lu_and_mt_sms_paging_repeated

Change-Id: Ie914ea88f31ac158f4bd1700143bbe728dd05e0b
---
M msc/MSC_Tests.ttcn
1 file changed, 28 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/01/16301/1

diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index 1a16dbf..c4d407a 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -2030,11 +2030,37 @@

f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS");

+   f_logp("Expecting first Paging");
/* MSC->BSC: expect PAGING from MSC */
f_expect_paging();

-   /* MSC->BSC: expect PAGING from MSC */
-   f_expect_paging();
+   if (g_pars.ran_is_geran) {
+   f_logp("GERAN: expect no further Paging");
+   } else {
+   f_logp("UTRAN: expect more Paging");
+   }
+
+   timer T := 5.0;
+   T.start;
+   alt {
+   [g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) {
+   setverdict(fail, "GERAN should not repeat Paging, but received 
a second Paging");
+   mtc.stop;
+   }
+   [not g_pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, 
imsi_hex2oct(g_pars.imsi))) {
+   f_logp("UTRAN: second Paging received, as expected");
+   setverdict(pass);
+   }
+   [] T.timeout {
+   if (g_pars.ran_is_geran) {
+   f_logp("GERAN: No further Paging received, as 
expected");
+   setverdict(pass);
+   } else {
+   setverdict(fail, "UTRAN: Expected a second Paging");
+   mtc.stop;
+   }
+   }
+   }

/* Establish DTAP / BSSAP / SCCP connection */
f_establish_fully(EST_TYPE_PAG_RESP);

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16301
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ie914ea88f31ac158f4bd1700143bbe728dd05e0b
Gerrit-Change-Number: 16301
Gerrit-PatchSet: 1
Gerrit-Owner: neels 
Gerrit-MessageType: newchange


Change in osmo-ttcn3-hacks[master]: msc: Iu: fix missing 'ran_is_geran := false' for TC_iu_lu_and_mt_sms_...

2019-11-27 Thread neels
neels has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16300 )


Change subject: msc: Iu: fix missing 'ran_is_geran := false' for 
TC_iu_lu_and_mt_sms_paging_repeated
..

msc: Iu: fix missing 'ran_is_geran := false' for 
TC_iu_lu_and_mt_sms_paging_repeated

Change-Id: I011795cacf62f2cac6861fe657966795e6370ddb
---
M msc/MSC_Tests_Iu.ttcn
1 file changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/00/16300/1

diff --git a/msc/MSC_Tests_Iu.ttcn b/msc/MSC_Tests_Iu.ttcn
index 198471d..2ef8505 100644
--- a/msc/MSC_Tests_Iu.ttcn
+++ b/msc/MSC_Tests_Iu.ttcn
@@ -301,7 +301,7 @@
var BSC_ConnHdlrPars pars;
var BSC_ConnHdlr vc_conn;
f_init(3);
-   pars := f_init_pars(101844);
+   pars := f_init_pars(101844, ran_idx := 2, ran_is_geran := false);
vc_conn := 
f_start_handler_with_pars(refers(f_tc_lu_and_mt_sms_paging_repeated), pars);
vc_conn.done;
 }

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16300
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I011795cacf62f2cac6861fe657966795e6370ddb
Gerrit-Change-Number: 16300
Gerrit-PatchSet: 1
Gerrit-Owner: neels 
Gerrit-MessageType: newchange


Change in osmo-ttcn3-hacks[master]: msc: fix 2 Iu tests: use f_mm_common() instead of f_mm_auth()

2019-11-27 Thread neels
neels has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16299 )


Change subject: msc: fix 2 Iu tests: use f_mm_common() instead of f_mm_auth()
..

msc: fix 2 Iu tests: use f_mm_common() instead of f_mm_auth()

Fix these tests by using f_mm_common(), which takes care of Iu auth+ciph:
TC_iu_lu_imsi_reject
TC_iu_lu_imsi_timeout_gsup

Change-Id: Id2bf160ac4e1cad4770202c6a6f1b8e21d68
---
M msc/MSC_Tests.ttcn
1 file changed, 2 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/99/16299/1

diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index 1b28b19..1a16dbf 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -486,7 +486,7 @@

f_create_gsup_expect(hex2str(g_pars.imsi));
f_cl3_or_initial_ue(l3_lu);
-   f_mm_auth();
+   f_mm_common();
GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi));
GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23));
alt {
@@ -516,7 +516,7 @@

f_create_gsup_expect(hex2str(g_pars.imsi));
f_cl3_or_initial_ue(l3_lu);
-   f_mm_auth();
+   f_mm_common();
GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi));
/* Normally the HLR would need to respond here, but we decide to force 
a timeout here */
alt {

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16299
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Id2bf160ac4e1cad4770202c6a6f1b8e21d68
Gerrit-Change-Number: 16299
Gerrit-PatchSet: 1
Gerrit-Owner: neels 
Gerrit-MessageType: newchange


Change in osmo-ttcn3-hacks[master]: msc: add tests for SMS and voice call while Paging

2019-11-27 Thread neels
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16297

to look at the new patch set (#2).

Change subject: msc: add tests for SMS and voice call while Paging
..

msc: add tests for SMS and voice call while Paging

Start a second
- MT SMS
- MT call
while a Paging is already ongoing.

The second trans being an SMS works.

The second trans being a call fails with current osmo-msc master; a fix is in
the related patch (s.b.).

Related: Idd4537b5f4817d17e5c87d9a93775a32aee0e7be
Change-Id: Ieeae6322d4e80893ea3408c6b74bf8e32bea8e46
---
M msc/BSC_ConnectionHandler.ttcn
M msc/MSC_Tests.ttcn
M msc/MSC_Tests_Iu.ttcn
3 files changed, 147 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/97/16297/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16297
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ieeae6322d4e80893ea3408c6b74bf8e32bea8e46
Gerrit-Change-Number: 16297
Gerrit-PatchSet: 2
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in osmo-msc[master]: fix incoming call while Paging

2019-11-27 Thread neels
neels has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-msc/+/16298 )


Change subject: fix incoming call while Paging
..

fix incoming call while Paging

Do not free the CC transaction when an MT subscriber is already being Paged.
Instead, invoke another paging request, which paging.c will correctly add to
the list of pending paging response callbacks to run.

A ttcn3 test is linked in the related patch (s.b.).

Related: OS#4240
Related: Ieeae6322d4e80893ea3408c6b74bf8e32bea8e46
Change-Id: Idd4537b5f4817d17e5c87d9a93775a32aee0e7be
---
M src/libmsc/gsm_04_08_cc.c
1 file changed, 2 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/98/16298/1

diff --git a/src/libmsc/gsm_04_08_cc.c b/src/libmsc/gsm_04_08_cc.c
index 4e604e5..8cfb611 100644
--- a/src/libmsc/gsm_04_08_cc.c
+++ b/src/libmsc/gsm_04_08_cc.c
@@ -1935,19 +1935,11 @@
 * log it now. */
LOG_TRANS_CAT(trans, DMNCC, LOGL_DEBUG, "rx %s\n", 
get_mncc_name(msg->msg_type));

-   if (vsub->cs.is_paging) {
-   LOG_TRANS(trans, LOGL_DEBUG,
- "rx %s, subscriber not yet connected, 
paging already started\n",
- get_mncc_name(msg->msg_type));
-   vlr_subscr_put(vsub, __func__);
-   trans_free(trans);
-   return 0;
-   }
-
/* store setup information until paging succeeds */
memcpy(&trans->cc.msg, data, sizeof(struct gsm_mncc));

-   /* Request a channel */
+   /* Request a channel. If Paging already started, 
paging_request_start() will append the new
+* trans to the already ongoing Paging. */
trans->paging_request = paging_request_start(vsub, 
PAGING_CAUSE_CALL_CONVERSATIONAL,
 
cc_paging_cb, trans, "MNCC: establish call");
if (!trans->paging_request) {

--
To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/16298
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: Idd4537b5f4817d17e5c87d9a93775a32aee0e7be
Gerrit-Change-Number: 16298
Gerrit-PatchSet: 1
Gerrit-Owner: neels 
Gerrit-MessageType: newchange


Change in osmo-ttcn3-hacks[master]: msc: add tests for SMS and voice call while Paging

2019-11-27 Thread neels
neels has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16297 )


Change subject: msc: add tests for SMS and voice call while Paging
..

msc: add tests for SMS and voice call while Paging

Start a second
- MT SMS
- MT call
while a Paging is already ongoing.

The second trans being an SMS works.

The second trans being a call fails with current osmo-msc master; a fix is in
the related patch (s.b.).

Related: Idd4537b5f4817d17e5c87d9a93775a32aee0e7be
Change-Id: Ieeae6322d4e80893ea3408c6b74bf8e32bea8e46
---
M msc/BSC_ConnectionHandler.ttcn
M msc/MSC_Tests.ttcn
2 files changed, 129 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/97/16297/1

diff --git a/msc/BSC_ConnectionHandler.ttcn b/msc/BSC_ConnectionHandler.ttcn
index 0846c04..aaacd06 100644
--- a/msc/BSC_ConnectionHandler.ttcn
+++ b/msc/BSC_ConnectionHandler.ttcn
@@ -1754,22 +1754,25 @@
f_mo_sms_wait_rp_ack(spars);
 }

+function f_mt_sms_expect_deliver_pdu(in SmsParameters spars)
+runs on BSC_ConnHdlr
+return template PDU_DTAP_MT {
+   var template TPDU_RP_DATA_SGSN_MS tp_mt := tr_SMS_DELIVER(?, 
spars.tp.ud, spars.tp.pid, spars.tp.dcs, ?);
+   var template RPDU_SGSN_MS rp_mt := tr_RP_DATA_MT(?, ?, omit, tp_mt);
+   var template PDU_ML3_NW_MS l3_mt := tr_ML3_MT_SMS(?, c_TIF_ORIG, 
tr_CP_DATA_MT(rp_mt));
+   return tr_PDU_DTAP_MT(l3_mt, spars.dlci);
+}
+
 /* Wait for MT SMS on an already existing DTAP connection */
 function f_mt_sms_expect(inout SmsParameters spars)
 runs on BSC_ConnHdlr {
var template (value) PDU_ML3_MS_NW l3_mo;
-   var template TPDU_RP_DATA_SGSN_MS tp_mt;
-   var template RPDU_SGSN_MS rp_mt;
-   var template PDU_ML3_NW_MS l3_mt;
var PDU_DTAP_MT dtap_mt;

var default d := activate(as_other_sms());

/* Expect CP-DATA(RP-DATA(SMS-DELIVER)) */
-   tp_mt := tr_SMS_DELIVER(?, spars.tp.ud, spars.tp.pid, spars.tp.dcs, ?);
-   rp_mt := tr_RP_DATA_MT(?, ?, omit, tp_mt);
-   l3_mt := tr_ML3_MT_SMS(?, c_TIF_ORIG, tr_CP_DATA_MT(rp_mt));
-   BSSAP.receive(tr_PDU_DTAP_MT(l3_mt, spars.dlci)) -> value dtap_mt;
+   BSSAP.receive(f_mt_sms_expect_deliver_pdu(spars)) -> value dtap_mt;

/* Extract relevant identifiers */
spars.tid := bit2int(dtap_mt.dtap.tiOrSkip.transactionId.tio);
diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index 480ec96..1b28b19 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -165,6 +165,14 @@
};
 }

+private function f_logp(charstring log_msg) runs on BSC_ConnHdlr
+{
+// log on TTCN3 log output
+log(log_msg);
+// log in stderr log
+   f_vty_transceive(MSCVTY, "logp lglobal notice " & log_msg);
+}
+
 /* altstep for the global guard timer (only used when BSSAP_DIRECT
  * is used for communication */
 private altstep as_Tguard_direct() runs on MTC_CT {
@@ -1895,6 +1903,54 @@
vc_conn.done;
 }

+/* SMS added while already Paging */
+friend function f_tc_lu_and_mt_sms_already_paging(charstring id, 
BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
+   var SmsParameters spars := valueof(t_SmsPars);
+   var OCT4 tmsi;
+
+   f_init_handler(pars);
+
+   /* Perform location update and call */
+   f_perform_lu();
+
+   /* register an 'expect' for given IMSI (+TMSI) */
+   if (isvalue(g_pars.tmsi)) {
+   tmsi := g_pars.tmsi;
+   } else {
+   tmsi := ''O;
+   }
+   f_ran_register_imsi(g_pars.imsi, tmsi);
+
+   f_logp("first SMS");
+   f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS");
+
+   /* MSC->BSC: expect PAGING from MSC */
+   f_expect_paging();
+
+   f_logp("second SMS");
+   /* Now osmo-msc is in state "Paging pending", make sure that another 
SMS to be sent at this time just joins in
+* with the pending paging. Another SMS: */
+   f_vty_sms_send(hex2str(pars.imsi), "2342", "Another SMS");
+
+   /* Establish DTAP / BSSAP / SCCP connection */
+   f_establish_fully(EST_TYPE_PAG_RESP);
+
+   spars.tp.ud := 'C8329BFD064D9B53'O;
+   f_mt_sms(spars);
+
+   spars.tp.ud := '41F79B8E2ECB41D3E614'O;
+   f_mt_sms(spars);
+
+   f_expect_clear();
+}
+testcase TC_lu_and_mt_sms_already_paging() runs on MTC_CT {
+   var BSC_ConnHdlrPars pars;
+   var BSC_ConnHdlr vc_conn;
+   f_init();
+   pars := f_init_pars(43);
+   vc_conn := 
f_start_handler_with_pars(refers(f_tc_lu_and_mt_sms_already_paging), pars);
+   vc_conn.done;
+}

 /* Paging for MT SMS but no response */
 friend function f_tc_lu_and_mt_sms_paging_and_nothing(charstring id, 
BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
@@ -4915,6 +4971,67 @@
vc_conn.done;
 }

+/* MT call while already Paging */
+friend function f_tc_lu_and_mt_call_already_paging(charstring id, 
BSC_ConnHdlrPars pars) runs on BSC_ConnHdl

Change in simtrace2[master]: simtrace2-sniff.c: fix printf usage

2019-11-27 Thread laforge
Hello osmith,

I'd like you to do a code review. Please visit

https://gerrit.osmocom.org/c/simtrace2/+/16296

to review the following change.


Change subject: simtrace2-sniff.c: fix printf usage
..

simtrace2-sniff.c: fix printf usage

Fixes:

simtrace2-sniff.c:113:4: error: format not a string literal and no format 
arguments [-Werror=format-security]
printf(flag_meanings[i].str);

Change-Id: I9793c680f070e724ce89272e9e489963c7516d52
---
M host/src/simtrace2-sniff.c
1 file changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/96/16296/1

diff --git a/host/src/simtrace2-sniff.c b/host/src/simtrace2-sniff.c
index 7e8e5eb..b2ce4a0 100644
--- a/host/src/simtrace2-sniff.c
+++ b/host/src/simtrace2-sniff.c
@@ -110,7 +110,7 @@
uint32_t i;
for (i = 0; i < nb_flags; i++) {
if (flags & flag_meanings[i].value) {
-   printf(flag_meanings[i].str);
+   printf("%s", flag_meanings[i].str);
flags &= ~flag_meanings[i].value;
if (flags) {
printf(", ");

--
To view, visit https://gerrit.osmocom.org/c/simtrace2/+/16296
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I9793c680f070e724ce89272e9e489963c7516d52
Gerrit-Change-Number: 16296
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: osmith 
Gerrit-MessageType: newchange


Change in libosmocore[master]: Introduce fields related to DTAP DLCI

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/16259 )

Change subject: Introduce fields related to DTAP DLCI
..


Patch Set 2: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/16259
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Iec448af02d28e6c5c573e68a0b4a86067ec7e561
Gerrit-Change-Number: 16259
Gerrit-PatchSet: 2
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:07:02 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: fix power descriptor value

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16283 )

Change subject: fix power descriptor value
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16283
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I40c48ea56151d13de362b8f73cae5b21aba0ebfa
Gerrit-Change-Number: 16283
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:04:38 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: better ccid error handling, fix buffer leaks

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16282 )

Change subject: better ccid error handling, fix buffer leaks
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16282
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ib8b8524809e12608a7ade79ce7d7c3ced16eeb57
Gerrit-Change-Number: 16282
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:04:21 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: add some volatility to debug missing state changes

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16281 )

Change subject: add some volatility to debug missing state changes
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16281
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I2e12e32ad27b03d73ba3533903c34abc2fcce37a
Gerrit-Change-Number: 16281
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:04:04 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: add a "no rx or tx" state

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16279 )

Change subject: add a "no rx or tx" state
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16279
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I27def4feff5a01b751fd48c5aa844ffdbb087f63
Gerrit-Change-Number: 16279
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:03:42 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: switching rx/tx is too slow, and not necessary

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16280 )

Change subject: switching rx/tx is too slow, and not necessary
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16280
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ic91b3e183ba451b4e327e407aae0497273652f56
Gerrit-Change-Number: 16280
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:03:55 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: debug code to use the DWT unit

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16277 )

Change subject: debug code to use the DWT unit
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16277
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ide6e34425e77425b260139ac1b4c528953a994f4
Gerrit-Change-Number: 16277
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:03:02 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: debug code to measure uart timing using the CAN header

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16278 )

Change subject: debug code to measure uart timing using the CAN header
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16278
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I5f2c174076b5599dcb56f887330de27f470aeffc
Gerrit-Change-Number: 16278
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:03:17 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: increase the debug uart buffer size

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16276 )

Change subject: increase the debug uart buffer size
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16276
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I343b03d5b06962b90f0c1aaceda03aa871a2f98b
Gerrit-Change-Number: 16276
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:02:48 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: attempt at handling card insertion/removal

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16275 )

Change subject: attempt at handling card insertion/removal
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16275
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I88130de7f889811425c0a2ca4063ea8822c83f66
Gerrit-Change-Number: 16275
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:02:28 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: cuart icc clock freq and divider setting support

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16273 )

Change subject: cuart icc clock freq and divider setting support
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16273
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I9c99c68511d3972513348ee6be5e7bb3b3a5f99e
Gerrit-Change-Number: 16273
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:01:34 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: ccid setparameters/PPS support

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16274 )

Change subject: ccid setparameters/PPS support
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16274
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I280969ec9fe681dedae14ae8e6806f69eed3ff5a
Gerrit-Change-Number: 16274
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:02:05 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: no logging, no memory pool

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16270 )

Change subject: no logging, no memory pool
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16270
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Iaf5123ab0340efec7b8e11e689f529f2e95e31ca
Gerrit-Change-Number: 16270
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:00:53 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: move iso7816_3 to common dir

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16272 )

Change subject: move iso7816_3 to common dir
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16272
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Id8cfc9247988ae999f5544d936d67f12e3902b92
Gerrit-Change-Number: 16272
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:01:16 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: prevent uart interrupts before having proper structs

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16271 )

Change subject: prevent uart interrupts before having proper structs
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16271
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I9cf7ff883721211ae11821339505d2e3b2a7961e
Gerrit-Change-Number: 16271
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:01:01 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: talloc asserts

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16269 )

Change subject: talloc asserts
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16269
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I00df6e41f38eba6b6f06a0dab52035f446718a99
Gerrit-Change-Number: 16269
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:00:34 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: increase the uart ring buffer size

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16268 )

Change subject: increase the uart ring buffer size
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16268
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Id4b4691dd32d465f627ba42c0ba3d509dcf8f42c
Gerrit-Change-Number: 16268
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:00:20 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: split usb descriptor code

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16266 )

Change subject: split usb descriptor code
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16266
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I9eb3606cfbaecf81f7ae80a9ea3d061a39088760
Gerrit-Change-Number: 16266
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 18:59:39 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: sercom config for t1

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16265 )

Change subject: sercom config for t1
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16265/1//COMMIT_MSG
Commit Message:

https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16265/1//COMMIT_MSG@9
PS1, Line 9: t0 doesn't work
it would be good to have a statement about what doesn't work, or what kind of 
observations have been made.



--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16265
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ie6cb7ec51036f1de15c83b59d130f3cb85309594
Gerrit-Change-Number: 16265
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 18:59:08 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: don't wait for TCK if card only supports T0

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16264 )

Change subject: don't wait for TCK if card only supports T0
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16264/1//COMMIT_MSG
Commit Message:

https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16264/1//COMMIT_MSG@7
PS1, Line 7: don't wait for TCK if card only supports T0
is that stated in the spec? If so, it might be useful to state this here.



--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16264
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ice7bc4e603ef88258af41f61e14a06727add
Gerrit-Change-Number: 16264
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 18:58:39 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: WIP: attempt to use iso7816_fsm + Cuart from firmware

2019-11-27 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16263 )

Change subject: WIP: attempt to use iso7816_fsm + Cuart from firmware
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16263
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I9d65428edbd3e6c978024a255a65d4531f556f62
Gerrit-Change-Number: 16263
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 18:57:53 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: enable the final slot

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16294 )


Change subject: enable the final slot
..

enable the final slot

The debug uart is shared with slot 7, so in order to use sim slot 7 the
pin config and the uart config needs to be changed. Going back to using
the debug uart works by defining ENABLE_DBG_UART7

Change-Id: I8f3c7c60306941159c35307a5c1e38c2a2bd2fe1
---
M sysmoOCTSIM/atmel_start.c
M sysmoOCTSIM/atmel_start_pins.h
M sysmoOCTSIM/command.c
M sysmoOCTSIM/config/hpl_sercom_config.h
M sysmoOCTSIM/cuart_driver_asf4_usart_async.c
M sysmoOCTSIM/driver_init.c
M sysmoOCTSIM/driver_init.h
M sysmoOCTSIM/gcc/Makefile
M sysmoOCTSIM/libosmo_emb.c
M sysmoOCTSIM/main.c
D sysmoOCTSIM/manual_test.c
M sysmoOCTSIM/stdio_start.c
12 files changed, 353 insertions(+), 264 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/94/16294/1

diff --git a/sysmoOCTSIM/atmel_start.c b/sysmoOCTSIM/atmel_start.c
index 6670364..931a09a 100644
--- a/sysmoOCTSIM/atmel_start.c
+++ b/sysmoOCTSIM/atmel_start.c
@@ -14,6 +14,8 @@
system_init();
dma_memory_init();
dma_memory_register_callback(DMA_MEMORY_COMPLETE_CB, 
M2M_DMA_complete_cb);
-// stdio_redirect_init();
+#ifdef ENABLE_DBG_UART7
+   stdio_redirect_init();
+#endif
usb_init();
 }
diff --git a/sysmoOCTSIM/atmel_start_pins.h b/sysmoOCTSIM/atmel_start_pins.h
index 7cbaed5..0c33536 100644
--- a/sysmoOCTSIM/atmel_start_pins.h
+++ b/sysmoOCTSIM/atmel_start_pins.h
@@ -60,6 +60,7 @@
 #define SWITCH GPIO(GPIO_PORTC, 14)
 #define MUX_STAT GPIO(GPIO_PORTC, 15)
 #define SIM6_IO GPIO(GPIO_PORTC, 16)
+#define SIM7_IO GPIO(GPIO_PORTB, 21)
 #define USER_LED GPIO(GPIO_PORTC, 26)
 #define SCL4 GPIO(GPIO_PORTC, 27)
 #define SDA4 GPIO(GPIO_PORTC, 28)
diff --git a/sysmoOCTSIM/command.c b/sysmoOCTSIM/command.c
index 454cd2f..48d8c11 100644
--- a/sysmoOCTSIM/command.c
+++ b/sysmoOCTSIM/command.c
@@ -78,6 +78,7 @@

 void command_try_recv(void)
 {
+#ifdef ENABLE_DBG_UART7
unsigned int i = 0;

/* yield CPU after maximum of 10 received characters */
@@ -101,6 +102,7 @@

i++;
}
+#endif
 }

 void command_init(const char *prompt)
diff --git a/sysmoOCTSIM/config/hpl_sercom_config.h 
b/sysmoOCTSIM/config/hpl_sercom_config.h
index bb2bbff..86b4c0a 100644
--- a/sysmoOCTSIM/config/hpl_sercom_config.h
+++ b/sysmoOCTSIM/config/hpl_sercom_config.h
@@ -1910,6 +1910,8 @@

 #include 

+#ifdef ENABLE_DBG_UART7
+
 #ifndef CONF_SERCOM_7_USART_ENABLE
 #define CONF_SERCOM_7_USART_ENABLE 1
 #endif
@@ -2176,7 +2178,281 @@
 #define CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH 0
 #endif
 #endif
+#else

+#include 
+
+#ifndef CONF_SERCOM_7_USART_ENABLE
+#define CONF_SERCOM_7_USART_ENABLE 1
+#endif
+
+//  Basic Configuration
+
+//  Receive buffer enable
+//  Enable input buffer in SERCOM module
+//  usart_rx_enable
+#ifndef CONF_SERCOM_7_USART_RXEN
+#define CONF_SERCOM_7_USART_RXEN 1
+#endif
+
+//  Transmitt buffer enable
+//  Enable output buffer in SERCOM module
+//  usart_tx_enable
+#ifndef CONF_SERCOM_7_USART_TXEN
+#define CONF_SERCOM_7_USART_TXEN 1
+#endif
+
+//  Frame parity
+// <0x1=>Even parity
+//  Parity bit mode for USART frame
+//  usart_parity
+#ifndef CONF_SERCOM_7_USART_PARITY
+#define CONF_SERCOM_7_USART_PARITY 1
+#endif
+
+//  Character Size
+// <0x0=>8 bits
+// <0x1=>9 bits
+// <0x5=>5 bits
+// <0x6=>6 bits
+// <0x7=>7 bits
+//  Data character size in USART frame
+//  usart_character_size
+#ifndef CONF_SERCOM_7_USART_CHSIZE
+#define CONF_SERCOM_7_USART_CHSIZE 0x0
+#endif
+
+//  Stop Bit
+// <0=>One stop bit
+// <1=>Two stop bits
+//  Number of stop bits in USART frame
+//  usart_stop_bit
+#ifndef CONF_SERCOM_7_USART_SBMODE
+#define CONF_SERCOM_7_USART_SBMODE 1
+#endif
+
+//  Baud rate <1-300>
+//  USART baud rate setting
+//  usart_baud_rate
+#ifndef CONF_SERCOM_7_USART_BAUD
+#define CONF_SERCOM_7_USART_BAUD 6720
+#endif
+// 
+
+//  ISO7816 configuration
+//  ISO7816 Protocol Type
+// <0x1=> T=0
+// <0x0=> T=1
+//  Define ISO7816 protocol type as 0.
+//  usart_iso7816_type
+#ifndef CONF_SERCOM_7_USART_ISO7816_PROTOCOL_T
+#define CONF_SERCOM_7_USART_ISO7816_PROTOCOL_T 0x0
+#endif
+
+//  ISO7816 Inhibit Not Acknowledge
+// <0x0=> NACK is transmitted when a parity error is received.
+// <0x1=> NACK is not transmitted when a parity error is received.
+//  Define whether a NACK is transmitted when a parity error is received.
+//  usart_inack
+#ifndef CONF_SERCOM_7_USART_INACK
+#define CONF_SERCOM_7_USART_INACK 0x0
+#endif
+
+//  ISO7816 Disable Successive Not Acknowledge
+// <0x0=> The successive receive NACK is disable.
+// <0x1=> The successive receive NACK is enable.
+//  Define whether NACK will be sent on parity error reception.
+//  usart_dsnack
+#ifndef CONF_SERCOM_7_USART_DSNACK
+#define CONF_SERCOM_7_USART_DSNACK 0x0
+#endif
+
+//  ISO7816 Maximum Iterations<0-7>
+//  De

Change in osmo-ccid-firmware[master]: boost uart priority

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16287 )


Change subject: boost uart priority
..

boost uart priority

Change-Id: I10ea17ca8b120c09b8926da010c9e358b219f7ed
---
M sysmoOCTSIM/main.c
1 file changed, 6 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/87/16287/1

diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index 806a9f6..c73b715 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -474,6 +474,12 @@
board_init();
command_init("sysmoOCTSIM> ");

+   /* boost uart priority by setting all other irqs to uartprio+1 */
+   for(int i = 0; i < PERIPH_COUNT_IRQn; i++)
+   NVIC_SetPriority(i, 2);
+   for(int i = SERCOM0_0_IRQn; i <= SERCOM7_3_IRQn; i++)
+   NVIC_SetPriority(i, 1);
+
printf("\r\n\r\n"

"=\n\r"
"sysmoOCTSIM firmware " GIT_VERSION "\n\r"

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16287
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I10ea17ca8b120c09b8926da010c9e358b219f7ed
Gerrit-Change-Number: 16287
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: change uart ctl define names

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16289 )


Change subject: change uart ctl define names
..

change uart ctl define names

Change-Id: I656e9e32c67d6e7b70a53f8f113583f25619e00f
---
M ccid_common/ccid_slot_fsm.c
M ccid_common/cuart.h
M sysmoOCTSIM/cuart_driver_asf4_usart_async.c
3 files changed, 6 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/89/16289/1

diff --git a/ccid_common/ccid_slot_fsm.c b/ccid_common/ccid_slot_fsm.c
index fef1515..3a591d7 100644
--- a/ccid_common/ccid_slot_fsm.c
+++ b/ccid_common/ccid_slot_fsm.c
@@ -195,8 +195,8 @@
 * - after ATR while card is idle
 * - after PPS while card is idle
 */
-   card_uart_ctrl(ss->cuart, CUART_CTL_CLOCK_FREQ, fmax);
-   card_uart_ctrl(ss->cuart, CUART_CTL_FD, F/D);
+   card_uart_ctrl(ss->cuart, CUART_CTL_SET_CLOCK_FREQ, fmax);
+   card_uart_ctrl(ss->cuart, CUART_CTL_SET_FD, F/D);
card_uart_ctrl(ss->cuart, CUART_CTL_WTIME, 
cs->proposed_pars.t0.waiting_integer);

cs->pars = cs->proposed_pars;
diff --git a/ccid_common/cuart.h b/ccid_common/cuart.h
index 32a8daa..c72b51c 100644
--- a/ccid_common/cuart.h
+++ b/ccid_common/cuart.h
@@ -26,10 +26,10 @@
CUART_CTL_NO_RXTX,  /* enable/disable receiver */
CUART_CTL_POWER,/* enable/disable ICC power */
CUART_CTL_CLOCK,/* enable/disable ICC clock */
-   CUART_CTL_CLOCK_FREQ, /* set ICC clock frequency (hz)*/
+   CUART_CTL_SET_CLOCK_FREQ, /* set ICC clock frequency (hz)*/
CUART_CTL_RST,  /* enable/disable ICC reset */
CUART_CTL_WTIME,/* set the waiting time (in etu) */
-   CUART_CTL_FD,
+   CUART_CTL_SET_FD,
 };

 struct card_uart;
diff --git a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c 
b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
index a0b3821..db3dc79 100644
--- a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
+++ b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
@@ -384,7 +384,7 @@
case CUART_CTL_CLOCK:
/* no clock stop support */
break;
-   case CUART_CTL_CLOCK_FREQ:
+   case CUART_CTL_SET_CLOCK_FREQ:
ncn8025_get(cuart->u.asf4.slot_nr, &settings);

/* 2,5/5/10/20 supported by dividers */
@@ -398,7 +398,7 @@
settings.clkdiv = clkdiv;
ncn8025_set(cuart->u.asf4.slot_nr, &settings);
break;
-   case CUART_CTL_FD:
+   case CUART_CTL_SET_FD:
ncn8025_get(cuart->u.asf4.slot_nr, &settings);
uint8_t divider = ncn8025_div_val[settings.clkdiv];
uint32_t baudrate = (20e6/divider)/arg;

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16289
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I656e9e32c67d6e7b70a53f8f113583f25619e00f
Gerrit-Change-Number: 16289
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: prettier slot bitmask code

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16295 )


Change subject: prettier slot bitmask code
..

prettier slot bitmask code

Change-Id: Ia70c589c06d8d786afac54063d41e775e8d850c2
---
M sysmoOCTSIM/main.c
1 file changed, 2 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/95/16295/1

diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index e3d7034..07c5af8 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -273,8 +273,8 @@

for(int i = 0; i <8; i++) {
uint8_t byteidx = i >> 2;
-   uint8_t old_bit = old_bm & (1 << i);
-   uint8_t new_bit = new_bm & (1 << i);
+   uint8_t old_bit = (old_bm >> i) & 1;
+   uint8_t new_bit = (new_bm >> i) & 1;
uint8_t bv;
if (old_bit == new_bit && new_bit == 0)
bv = 0x00;

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16295
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ia70c589c06d8d786afac54063d41e775e8d850c2
Gerrit-Change-Number: 16295
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: first attempt at rx timeout handling

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16293 )


Change subject: first attempt at rx timeout handling
..

first attempt at rx timeout handling

The general idea is to provide hints to cuart so it can calculate
a reasonable timeout value when receiving multiple bytes instead of
having per-byte timeouts

Change-Id: Ia6ad2d83cea48a8661ed2e4eb50f9bcb85218454
---
M ccid_common/cuart.c
M ccid_common/cuart.h
M ccid_common/iso7816_fsm.c
3 files changed, 143 insertions(+), 29 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/93/16293/1

diff --git a/ccid_common/cuart.c b/ccid_common/cuart.c
index 1ae50c6..1d777f9 100644
--- a/ccid_common/cuart.c
+++ b/ccid_common/cuart.c
@@ -49,7 +49,12 @@
 {
int secs, usecs;
 
-   usecs = get_etu_in_us(cuart) * cuart->wtime_etu;
+   if(!cuart->current_wtime_byte)
+   return;
+
+   /* timemout is wtime * ETU + expected number of bytes * (12ETU+1 
slack)ETU */
+   usecs = get_etu_in_us(cuart) * cuart->wtime_etu +
+   get_etu_in_us(cuart) * cuart->current_wtime_byte * 
(12+1);
if (usecs > 100) {
secs = usecs / 100;
usecs = usecs % 100;
@@ -108,6 +113,15 @@
cuart->rx_enabled = arg ? true : false;
if (!cuart->rx_enabled)
osmo_timer_del(&cuart->wtime_tmr);
+// else
+// card_uart_wtime_restart(cuart);
+   break;
+   case CUART_CTL_RX_TIMER_HINT:
+   cuart->current_wtime_byte = arg;
+   if(arg)
+   card_uart_wtime_restart(cuart);
+   else
+   osmo_timer_del(&cuart->wtime_tmr);
break;
default:
break;
@@ -158,6 +172,12 @@
if (cuart->rx_after_tx_compl)
card_uart_ctrl(cuart, CUART_CTL_RX, true);
break;
+// case CUART_E_RX_COMPLETE:
+// osmo_timer_del(&cuart->wtime_tmr);
+// break;
+// case CUART_E_RX_SINGLE:
+// card_uart_wtime_restart(cuart);
+// break;
default:
break;
}
diff --git a/ccid_common/cuart.h b/ccid_common/cuart.h
index 6a782db..1df0c49 100644
--- a/ccid_common/cuart.h
+++ b/ccid_common/cuart.h
@@ -23,6 +23,7 @@

 enum card_uart_ctl {
CUART_CTL_RX,   /* enable/disable receiver */
+   CUART_CTL_RX_TIMER_HINT, /* tell cuart approximate number of rx bytes */
CUART_CTL_NO_RXTX,  /* enable/disable receiver */
CUART_CTL_POWER,/* enable/disable ICC power */
CUART_CTL_CLOCK,/* enable/disable ICC clock */
@@ -78,6 +79,8 @@

uint32_t wtime_etu;
struct osmo_timer_list wtime_tmr;
+   /* expected number of bytes, for timeout */
+   uint32_t current_wtime_byte;

/* driver-specific private data */
union {
diff --git a/ccid_common/iso7816_fsm.c b/ccid_common/iso7816_fsm.c
index 44c8191..412bea7 100644
--- a/ccid_common/iso7816_fsm.c
+++ b/ccid_common/iso7816_fsm.c
@@ -68,14 +68,14 @@
  *  @note defined in ISO/IEC 7816-3:2006(E) section 9
  */
 enum pps_state {
-   PPS_S_TX_PPS_REQ,  /*!< tx pps request */
-   PPS_S_WAIT_PPSS, /*!< initial byte */
+   PPS_S_PPS_REQ_INIT,  /*!< tx pps request */
+   PPS_S_TX_PPS_REQ,
+   PPS_S_WAIT_PPSX, /*!< initial byte */
PPS_S_WAIT_PPS0, /*!< format byte */
PPS_S_WAIT_PPS1, /*!< first parameter byte */
PPS_S_WAIT_PPS2, /*!< second parameter byte */
PPS_S_WAIT_PPS3, /*!< third parameter byte */
PPS_S_WAIT_PCK, /*!< check byte */
-   PPS_S_WAIT_END, /*!< all done */
PPS_S_DONE
 };

@@ -219,9 +219,11 @@
struct iso7816_3_priv *ip = get_iso7816_3_priv(fi);
OSMO_ASSERT(fi->fsm == &iso7816_3_fsm);

+   card_uart_ctrl(ip->uart, CUART_CTL_RX_TIMER_HINT, 0);
+
/* go back to initial state in child FSMs */
osmo_fsm_inst_state_chg(ip->atr_fi, ATR_S_WAIT_TS, 0, 0);
-   osmo_fsm_inst_state_chg(ip->pps_fi, PPS_S_TX_PPS_REQ, 0, 0);
+   osmo_fsm_inst_state_chg(ip->pps_fi, PPS_S_PPS_REQ_INIT, 0, 0);
osmo_fsm_inst_state_chg(ip->tpdu_fi, TPDU_S_INIT, 0, 0);
 }

@@ -235,8 +237,13 @@
case ISO7816_E_RESET_REL_IND:
/* TOOD: this should happen before reset is released */
card_uart_ctrl(ip->uart, CUART_CTL_RX, true);
-   osmo_fsm_inst_state_chg_ms(fi, ISO7816_S_WAIT_ATR,
-  fi_cycles2ms(fi, 4), T_WAIT_ATR);
+
+   /* let's be reasonable here: the 40k cycle delay to ATR start is
+* ~1.4ms @ 2.5Mhz/6720 baud, 1ETU = 372 cycles -> 
40k/372=107/12ETU ~ 9 byte
+* default timeout for rx is 9600 E

Change in osmo-ccid-firmware[master]: cuart: fix etu calculation

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16291 )


Change subject: cuart: fix etu calculation
..

cuart: fix etu calculation

Change-Id: Ib2f83654bdaae5090bb1dfd75e0906551d6b6aa7
---
M ccid_common/cuart.c
1 file changed, 6 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/91/16291/1

diff --git a/ccid_common/cuart.c b/ccid_common/cuart.c
index 9a68167..1ae50c6 100644
--- a/ccid_common/cuart.c
+++ b/ccid_common/cuart.c
@@ -29,8 +29,12 @@
 /* obtain the current ETU in us */
 static int get_etu_in_us(struct card_uart *cuart)
 {
-   /* FIXME: actually implement this based on the real baud rate */
-   return (100/9600);
+   OSMO_ASSERT(cuart);
+   OSMO_ASSERT(cuart->driver);
+   OSMO_ASSERT(cuart->driver->ops);
+   OSMO_ASSERT(cuart->driver->ops->ctrl);
+
+   return 1e6 / cuart->driver->ops->ctrl(cuart, CUART_CTL_GET_BAUDRATE, 0);
 }

 /* software waiting-time timer has expired */

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16291
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ib2f83654bdaae5090bb1dfd75e0906551d6b6aa7
Gerrit-Change-Number: 16291
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: cuart: allow getting the icc baud rate and clock freq

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16290 )


Change subject: cuart: allow getting the icc baud rate and clock freq
..

cuart: allow getting the icc baud rate and clock freq

Change-Id: I577907e6c60582a80666d43b17c20de4e03cc8df
---
M ccid_common/cuart.h
M sysmoOCTSIM/cuart_driver_asf4_usart_async.c
2 files changed, 12 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/90/16290/1

diff --git a/ccid_common/cuart.h b/ccid_common/cuart.h
index c72b51c..6a782db 100644
--- a/ccid_common/cuart.h
+++ b/ccid_common/cuart.h
@@ -30,6 +30,8 @@
CUART_CTL_RST,  /* enable/disable ICC reset */
CUART_CTL_WTIME,/* set the waiting time (in etu) */
CUART_CTL_SET_FD,
+   CUART_CTL_GET_BAUDRATE,
+   CUART_CTL_GET_CLOCK_FREQ,
 };

 struct card_uart;
@@ -100,6 +102,7 @@
uint8_t slot_nr;
/* in us, required, no delay breaks _rx_ */
uint32_t extrawait_after_rx;
+   uint32_t current_baudrate;
} asf4;
} u;
 };
diff --git a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c 
b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
index db3dc79..f12ed73 100644
--- a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
+++ b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
@@ -203,6 +203,9 @@
if (NULL == slot) {
return false;
}
+
+   // update cached values
+   cuart->u.asf4.current_baudrate = baudrate;
printf("(%u) switching SERCOM clock to GCLK%u (freq = %lu kHz) and baud 
rate to %lu bps (baud = %u)\r\n", slotnr, (best + 1) * 2, 
(uint32_t)(round(sercom_glck_freqs[best] / 1000)), baudrate, bauds[best]);
while (!usart_async_is_tx_empty(slot)); // wait for transmission to 
complete (WARNING no timeout)
usart_async_disable(slot); // disable SERCOM peripheral
@@ -404,6 +407,12 @@
uint32_t baudrate = (20e6/divider)/arg;
cuart->u.asf4.extrawait_after_rx = 1./baudrate * 1000 * 1000;
slot_set_baudrate(cuart->u.asf4.slot_nr, baudrate);
+   case CUART_CTL_GET_BAUDRATE:
+   return cuart->u.asf4.current_baudrate;
+   break;
+   case CUART_CTL_GET_CLOCK_FREQ:
+   ncn8025_get(cuart->u.asf4.slot_nr, &settings);
+   return 20e6 / ncn8025_div_val[settings.clkdiv];
break;
default:
return -EINVAL;

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16290
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I577907e6c60582a80666d43b17c20de4e03cc8df
Gerrit-Change-Number: 16290
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: cuart cleanup

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16292 )


Change subject: cuart cleanup
..

cuart cleanup

Change-Id: I15ea4d68263b62fca3da76795969358a07e7f1a6
---
M sysmoOCTSIM/cuart_driver_asf4_usart_async.c
1 file changed, 15 insertions(+), 15 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/92/16292/1

diff --git a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c 
b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
index f12ed73..c7d29eb 100644
--- a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
+++ b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
@@ -161,8 +161,10 @@
  *  @param[in] baudrate baud rate in bps to set
  *  @return if the baud rate has been set, else a parameter is out of range
  */
-static bool slot_set_baudrate(uint8_t slotnr, uint32_t baudrate)
+static bool slot_set_baudrate(struct card_uart *cuart, uint32_t baudrate)
 {
+   uint8_t slotnr = cuart->u.asf4.slot_nr;
+
ASSERT(slotnr < ARRAY_SIZE(SIM_peripheral_descriptors));

// calculate the error corresponding to the clock sources
@@ -206,6 +208,8 @@

// update cached values
cuart->u.asf4.current_baudrate = baudrate;
+   cuart->u.asf4.extrawait_after_rx = 1./baudrate * 1000 * 1000;
+
printf("(%u) switching SERCOM clock to GCLK%u (freq = %lu kHz) and baud 
rate to %lu bps (baud = %u)\r\n", slotnr, (best + 1) * 2, 
(uint32_t)(round(sercom_glck_freqs[best] / 1000)), baudrate, bauds[best]);
while (!usart_async_is_tx_empty(slot)); // wait for transmission to 
complete (WARNING no timeout)
usart_async_disable(slot); // disable SERCOM peripheral
@@ -226,8 +230,10 @@
  *  @param[in] d baud rate adjustment factor D
  *  @return if the baud rate has been set, else a parameter is out of range
  */
-static bool slot_set_isorate(uint8_t slotnr, enum ncn8025_sim_clkdiv clkdiv, 
uint16_t f, uint8_t d)
+static bool slot_set_isorate(struct card_uart *cuart, enum ncn8025_sim_clkdiv 
clkdiv, uint16_t f, uint8_t d)
 {
+   uint8_t slotnr = cuart->u.asf4.slot_nr;
+
// input checks
ASSERT(slotnr < ARRAY_SIZE(SIM_peripheral_descriptors));
if (clkdiv != SIM_CLKDIV_1 && clkdiv != SIM_CLKDIV_2 && clkdiv != 
SIM_CLKDIV_4 && clkdiv != SIM_CLKDIV_8) {
@@ -267,7 +273,7 @@

// set baud rate
uint32_t baudrate = (freq * d) / f; // calculate actual baud rate
-   return slot_set_baudrate(slotnr, baudrate); // set baud rate
+   return slot_set_baudrate(cuart, baudrate); // set baud rate
 }

 /***
@@ -292,16 +298,13 @@
cuart->u.asf4.usa_pd = usa_pd;
cuart->u.asf4.slot_nr = slot_nr;

-   /* in us, 20Mhz with default ncn8025 divider 8, F=372, D=1*/
-   cuart->u.asf4.extrawait_after_rx = 1./(20./8/372);
-
usart_async_register_callback(usa_pd, USART_ASYNC_RXC_CB, 
SIM_rx_cb[slot_nr]);
usart_async_register_callback(usa_pd, USART_ASYNC_TXC_CB, 
SIM_tx_cb[slot_nr]);
usart_async_register_callback(usa_pd, USART_ASYNC_ERROR_CB, 
_SIM_error_cb);
usart_async_enable(usa_pd);

// set USART baud rate to match the interface (f = 2.5 MHz) and card 
default settings (Fd = 372, Dd = 1)
-   slot_set_isorate(cuart->u.asf4.slot_nr, SIM_CLKDIV_8, 
ISO7816_3_DEFAULT_FD, ISO7816_3_DEFAULT_DD);
+   slot_set_isorate(cuart, SIM_CLKDIV_8, ISO7816_3_DEFAULT_FD, 
ISO7816_3_DEFAULT_DD);

 return 0;
 }
@@ -352,6 +355,7 @@

switch (ctl) {
case CUART_CTL_NO_RXTX:
+   /* no op */
break;
case CUART_CTL_RX:
if (arg){
@@ -367,12 +371,8 @@
usart_async_flush_rx_buffer(cuart->u.asf4.usa_pd);
break;
case CUART_CTL_POWER:
-   /* in us, 20Mhz with default ncn8025 divider 8, F=372, D=1*/
-   cuart->u.asf4.extrawait_after_rx = 1./(20./8/372);
-
-   // set USART baud rate to match the interface (f = 2.5 MHz) and 
card default settings (Fd = 372, Dd = 1)
-   if(arg)
-   slot_set_isorate(cuart->u.asf4.slot_nr, SIM_CLKDIV_8, 
ISO7816_3_DEFAULT_FD, ISO7816_3_DEFAULT_DD);
+   /* reset everything */
+   slot_set_isorate(cuart, SIM_CLKDIV_8, ISO7816_3_DEFAULT_FD, 
ISO7816_3_DEFAULT_DD);

ncn8025_get(cuart->u.asf4.slot_nr, &settings);
settings.cmdvcc = arg ? true : false;
@@ -405,8 +405,8 @@
ncn8025_get(cuart->u.asf4.slot_nr, &settings);
uint8_t divider = ncn8025_div_val[settings.clkdiv];
uint32_t baudrate = (20e6/divider)/arg;
-   cuart->u.asf4.extrawait_after_rx = 1./baudrate * 1000 * 1000;
-   slot_set_baudrate(cuart->u.asf4.slot_nr, baudrate);
+   slot_set_baudrate(cuart, baudrate);
+   break;
   

Change in osmo-ccid-firmware[master]: prevent uart interrupts before having proper structs

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16271 )


Change subject: prevent uart interrupts before having proper structs
..

prevent uart interrupts before having proper structs

Change-Id: I9cf7ff883721211ae11821339505d2e3b2a7961e
---
M sysmoOCTSIM/main.c
1 file changed, 3 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/71/16271/1

diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index 0f2409a..7ddca92 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -470,6 +470,8 @@

LOGP(DUSB, LOGL_ERROR, "foobar usb\n");

+   //prevent spurious interrupts before our driver structs are ready
+   CRITICAL_SECTION_ENTER()
ccid_instance_init(&g_ci, &c_ops, &iso_fsm_slot_ops, 
&usb_fs_descs.ccid.class,
   data_rates, clock_freqs, "", 0);

@@ -480,6 +482,7 @@
llist_add_tail_at(&msg->list, &g_ccid_s.free_q);
}
submit_next_out();
+   CRITICAL_SECTION_LEAVE()

 // command_print_prompt();
while (true) { // main loop

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16271
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I9cf7ff883721211ae11821339505d2e3b2a7961e
Gerrit-Change-Number: 16271
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: WIP: attempt to use iso7816_fsm + Cuart from firmware

2019-11-27 Thread Hoernchen
Hello laforge,

I'd like you to do a code review. Please visit

https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16263

to review the following change.


Change subject: WIP: attempt to use iso7816_fsm + Cuart from firmware
..

WIP: attempt to use iso7816_fsm + Cuart from firmware

Change-Id: I9d65428edbd3e6c978024a255a65d4531f556f62
---
M ccid_host/ccid_slot_sim.c
M sysmoOCTSIM/gcc/Makefile
2 files changed, 6 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/63/16263/1

diff --git a/ccid_host/ccid_slot_sim.c b/ccid_host/ccid_slot_sim.c
index 1bd514a..dc33114 100644
--- a/ccid_host/ccid_slot_sim.c
+++ b/ccid_host/ccid_slot_sim.c
@@ -100,9 +100,10 @@
 {
if (enable) {
cs->icc_powered = true;
-   /* FIXME: What to do about ATR? */
+   cs->icc_in_reset = false;
} else {
cs->icc_powered = false;
+   cs->icc_in_reset = true;
}
 }

diff --git a/sysmoOCTSIM/gcc/Makefile b/sysmoOCTSIM/gcc/Makefile
index 595fd62..4840fea 100644
--- a/sysmoOCTSIM/gcc/Makefile
+++ b/sysmoOCTSIM/gcc/Makefile
@@ -83,6 +83,10 @@
atmel_start.o \
ccid_common/ccid_proto.o \
ccid_common/ccid_device.o \
+   ccid_common/iso7816_fsm.o \
+   ccid_common/cuart.o \
+   ccid_common/ccid_slot_fsm.o \
+   cuart_driver_asf4_usart_async.o \
command.o \
dma_m2m/dma_memory.o \
driver_init.o \

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16263
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I9d65428edbd3e6c978024a255a65d4531f556f62
Gerrit-Change-Number: 16263
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: laforge 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: split usb descriptor code

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16266 )


Change subject: split usb descriptor code
..

split usb descriptor code

Change-Id: I9eb3606cfbaecf81f7ae80a9ea3d061a39088760
---
M sysmoOCTSIM/main.c
M sysmoOCTSIM/usb/class/ccid/device/ccid_df.c
M sysmoOCTSIM/usb_descriptors.c
A sysmoOCTSIM/usb_descriptors.h
4 files changed, 105 insertions(+), 47 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/66/16266/1

diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index 15e2004..fed562b 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -43,6 +43,8 @@
 // TODO put declaration in more global file
 // TODO for now SIM7 is not present because used for debug
 static struct usart_async_descriptor* SIM_peripheral_descriptors[] = {&SIM0, 
&SIM1, &SIM2, &SIM3, &SIM4, &SIM5, &SIM6, NULL};
+#include "ccid_device.h"
+#include "usb_descriptors.h"

 /** number of bytes transmitted on the SIM peripheral */
 static volatile bool SIM_tx_count[8];
diff --git a/sysmoOCTSIM/usb/class/ccid/device/ccid_df.c 
b/sysmoOCTSIM/usb/class/ccid/device/ccid_df.c
index 65d3499..665f0fc 100644
--- a/sysmoOCTSIM/usb/class/ccid/device/ccid_df.c
+++ b/sysmoOCTSIM/usb/class/ccid/device/ccid_df.c
@@ -24,6 +24,9 @@
 #include "ccid_proto.h"
 #include "usb_includes.h"

+#include "cdcdf_acm_desc.h"
+#include "usb_descriptors.h"
+
 #ifndef USB_CLASS_CCID
 #defineUSB_CLASS_CCID  11
 #endif
@@ -40,9 +43,11 @@
 static struct usbdf_driver _ccid_df;
 static struct ccid_df_func_data _ccid_df_funcd;

+extern const struct usb_desc_collection usb_fs_descs;
+
 /* FIXME: make those configurable, ensure they're sized according to
  * bNumClockSupported / bNumDataRatesSupported */
-static uint32_t ccid_clock_frequencies[] = { LE32(2) };
+static uint32_t ccid_clock_frequencies[CCID_NUM_CLK_SUPPORTED] = { 
LE32(2500),LE32(5000),LE32(1),LE32(2) };
 static uint32_t ccid_baud_rates[] = { LE32(9600) };

 static int32_t ccid_df_enable(struct usbdf_driver *drv, struct 
usbd_descriptors *desc)
diff --git a/sysmoOCTSIM/usb_descriptors.c b/sysmoOCTSIM/usb_descriptors.c
index 944e43b..63ace0c 100644
--- a/sysmoOCTSIM/usb_descriptors.c
+++ b/sysmoOCTSIM/usb_descriptors.c
@@ -1,54 +1,32 @@
+/*
+ * Copyright (C) 2019 sysmocom -s.f.m.c. GmbH, Author: Eric Wild 

+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+*/
+
 #include "usbd_config.h"
 #include "usbdc.h"
 #include "usb_protocol.h"
 #include "usb_protocol_cdc.h"
 #include "ccid_proto.h"
 #include "cdcdf_acm_desc.h"
+#include "usb_descriptors.h"

-/* aggregate descriptors for the combined CDC-ACM + CCID device that we expose
- * from sysmoQMOD */

-enum str_desc_num {
-   STR_DESC_MANUF = 1,
-   STR_DESC_PRODUCT,
-   STR_DESC_CONFIG,
-   STR_DESC_INTF_ACM_COMM,
-   STR_DESC_INTF_ACM_DATA,
-   STR_DESC_INTF_CCID,
-   STR_DESC_SERIAL,
-};

-/* a struct of structs representing the concatenated collection of USB 
descriptors */
-struct usb_desc_collection {
-   struct usb_dev_desc dev;
-   struct usb_config_desc cfg;
-
-   /* CDC-ACM: Two interfaces, one with IRQ EP and one with BULK IN + OUT 
*/
-   struct {
-   struct {
-   struct usb_iface_desc iface;
-   struct usb_cdc_hdr_desc cdc_hdr;
-   struct usb_cdc_call_mgmt_desc cdc_call_mgmt;
-   struct usb_cdc_acm_desc cdc_acm;
-   struct usb_cdc_union_desc cdc_union;
-   struct usb_ep_desc ep[1];
-   } comm;
-   struct {
-   struct usb_iface_desc iface;
-   struct usb_ep_desc ep[2];
-   } data;
-   } cdc;
-
-   /* CCID: One interface with CCID class descriptor and three endpoints */
-   struct {
-   struct usb_iface_desc iface;
-   struct usb_ccid_class_descriptor class;
-   struct usb_ep_desc ep[3];
-   } ccid;
-   uint8_t str[116];
-} __attribute__((packed));
-
-static const struct usb_desc_collection usb_fs_descs = {
+const struct usb_desc_collection usb_fs_descs = {
.dev = {
.bLengt

Change in osmo-ccid-firmware[master]: the magic sauce that makes it work

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16288 )


Change subject: the magic sauce that makes it work
..

the magic sauce that makes it work

1mio concurrent select mf transfers, 5mhz, fi/di 512/32

Change-Id: Ica8539e4428ca3e3eb3e8ca9f5a5b50eb738ca8d
---
M sysmoOCTSIM/hpl/sercom/hpl_sercom.c
1 file changed, 4 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/88/16288/1

diff --git a/sysmoOCTSIM/hpl/sercom/hpl_sercom.c 
b/sysmoOCTSIM/hpl/sercom/hpl_sercom.c
index 272fb07..7373962 100644
--- a/sysmoOCTSIM/hpl/sercom/hpl_sercom.c
+++ b/sysmoOCTSIM/hpl/sercom/hpl_sercom.c
@@ -589,6 +589,8 @@

if (hri_sercomusart_get_interrupt_DRE_bit(hw) && 
hri_sercomusart_get_INTEN_DRE_bit(hw)) {
hri_sercomusart_clear_INTEN_DRE_bit(hw);
+   hri_sercomusart_read_DATA_reg(hw);
+   hri_sercomusart_clear_INTFLAG_RXC_bit(hw);
device->usart_cb.tx_byte_sent(device);
} else if (hri_sercomusart_get_interrupt_TXC_bit(hw) && 
hri_sercomusart_get_INTEN_TXC_bit(hw)) {
 #if 0
@@ -598,6 +600,8 @@
gpio_set_pin_level(PIN_PB12, false);
 #endif
hri_sercomusart_clear_INTEN_TXC_bit(hw);
+   hri_sercomusart_read_DATA_reg(hw);
+   hri_sercomusart_clear_INTFLAG_RXC_bit(hw);
device->usart_cb.tx_done_cb(device);
} else if (hri_sercomusart_get_interrupt_RXC_bit(hw)) {
if (hri_sercomusart_read_STATUS_reg(hw)

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16288
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ica8539e4428ca3e3eb3e8ca9f5a5b50eb738ca8d
Gerrit-Change-Number: 16288
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: increase the uart ring buffer size

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16268 )


Change subject: increase the uart ring buffer size
..

increase the uart ring buffer size

must be be a power of 2, and should be at least as large as the largest
transfer that we might be waiting for - revisit this, is 256 enough?

Change-Id: Id4b4691dd32d465f627ba42c0ba3d509dcf8f42c
---
M sysmoOCTSIM/driver_init.c
1 file changed, 7 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/68/16268/1

diff --git a/sysmoOCTSIM/driver_init.c b/sysmoOCTSIM/driver_init.c
index 620ed6c..c373dc2 100644
--- a/sysmoOCTSIM/driver_init.c
+++ b/sysmoOCTSIM/driver_init.c
@@ -12,25 +12,25 @@
 #include 

 /*! The buffer size for USART */
-#define SIM0_BUFFER_SIZE 16
+#define SIM0_BUFFER_SIZE 512

 /*! The buffer size for USART */
-#define SIM1_BUFFER_SIZE 16
+#define SIM1_BUFFER_SIZE 512

 /*! The buffer size for USART */
-#define SIM2_BUFFER_SIZE 16
+#define SIM2_BUFFER_SIZE 512

 /*! The buffer size for USART */
-#define SIM3_BUFFER_SIZE 16
+#define SIM3_BUFFER_SIZE 512

 /*! The buffer size for USART */
-#define SIM4_BUFFER_SIZE 16
+#define SIM4_BUFFER_SIZE 512

 /*! The buffer size for USART */
-#define SIM5_BUFFER_SIZE 16
+#define SIM5_BUFFER_SIZE 512
 
 /*! The buffer size for USART */
-#define SIM6_BUFFER_SIZE 16
+#define SIM6_BUFFER_SIZE 512

 /*! The buffer size for USART */
 #define UART_DEBUG_BUFFER_SIZE 256

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16268
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Id4b4691dd32d465f627ba42c0ba3d509dcf8f42c
Gerrit-Change-Number: 16268
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: don't wait for TCK if card only supports T0

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16264 )


Change subject: don't wait for TCK if card only supports T0
..

don't wait for TCK if card only supports T0

This could be handled by a timeout instead, but timeouts don't work yet.

Change-Id: Ice7bc4e603ef88258af41f61e14a06727add
---
M ccid_common/iso7816_fsm.c
1 file changed, 4 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/64/16264/1

diff --git a/ccid_common/iso7816_fsm.c b/ccid_common/iso7816_fsm.c
index 21378e0..beda7ab 100644
--- a/ccid_common/iso7816_fsm.c
+++ b/ccid_common/iso7816_fsm.c
@@ -633,6 +633,10 @@
osmo_fsm_inst_state_chg_ms(fi, 
ATR_S_WAIT_TCK,
   
guard_time_ms, T_GUARD);
break;
+   } else {
+   /* no TCK present, ATR complete; notify 
parent */
+   osmo_fsm_inst_state_chg(fi, ATR_S_DONE, 
0, 0);
+   osmo_fsm_inst_dispatch(fi->proc.parent, 
ISO7816_E_ATR_DONE_IND, atp->atr);
}
} else {
break;

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16264
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ice7bc4e603ef88258af41f61e14a06727add
Gerrit-Change-Number: 16264
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: fix power descriptor value

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16283 )


Change subject: fix power descriptor value
..

fix power descriptor value

The previous value would allow using the device
without external power, i.e. on a hub, which leads
to silent failures trying to power up the slots
(nothing happens, no atr will be received)

Change-Id: I40c48ea56151d13de362b8f73cae5b21aba0ebfa
FIXME: The device should offer at least one 100mA configuration.
---
M sysmoOCTSIM/usb_descriptors.c
1 file changed, 2 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/83/16283/1

diff --git a/sysmoOCTSIM/usb_descriptors.c b/sysmoOCTSIM/usb_descriptors.c
index 63ace0c..beb1633 100644
--- a/sysmoOCTSIM/usb_descriptors.c
+++ b/sysmoOCTSIM/usb_descriptors.c
@@ -52,7 +52,8 @@
.bConfigurationValue = CONF_USB_CDCD_ACM_BCONFIGVAL,
.iConfiguration = STR_DESC_CONFIG,
.bmAttributes = CONF_USB_CDCD_ACM_BMATTRI,
-   .bMaxPower = CONF_USB_CDCD_ACM_BMAXPOWER,
+   /* FIXME: The device should offer at least one 100mA 
configuration. */
+   .bMaxPower = 250, /* request 500mA */
},
.cdc = {
.comm = {

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16283
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I40c48ea56151d13de362b8f73cae5b21aba0ebfa
Gerrit-Change-Number: 16283
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: debug code to measure uart timing using the CAN header

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16278 )


Change subject: debug code to measure uart timing using the CAN header
..

debug code to measure uart timing using the CAN header

Change-Id: I5f2c174076b5599dcb56f887330de27f470aeffc
---
M ccid_common/iso7816_fsm.c
M sysmoOCTSIM/hpl/sercom/hpl_sercom.c
M sysmoOCTSIM/main.c
3 files changed, 37 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/78/16278/1

diff --git a/ccid_common/iso7816_fsm.c b/ccid_common/iso7816_fsm.c
index 98c32d3..031f6b0 100644
--- a/ccid_common/iso7816_fsm.c
+++ b/ccid_common/iso7816_fsm.c
@@ -1134,6 +1134,7 @@
}
 }

+#include 
 static void tpdu_s_tx_hdr_action(struct osmo_fsm_inst *fi, uint32_t event, 
void *data)
 {
OSMO_ASSERT(fi->fsm == &tpdu_fsm);
@@ -1173,6 +1174,12 @@
} else if (byte == tpduh->ins) {
if (tfp->is_command) {
/* transmit all remaining bytes */
+#if 0
+// rx -> tx delay
+   gpio_set_pin_level(PIN_PB12, true);
+   delay_us(1);
+   gpio_set_pin_level(PIN_PB12, false);
+#endif
card_uart_tx(ip->uart, msgb_l2(tfp->tpdu), 
msgb_l2len(tfp->tpdu), true);
osmo_fsm_inst_state_chg(fi, 
TPDU_S_TX_REMAINING, 0, 0);
} else {
diff --git a/sysmoOCTSIM/hpl/sercom/hpl_sercom.c 
b/sysmoOCTSIM/hpl/sercom/hpl_sercom.c
index f235115..272fb07 100644
--- a/sysmoOCTSIM/hpl/sercom/hpl_sercom.c
+++ b/sysmoOCTSIM/hpl/sercom/hpl_sercom.c
@@ -577,7 +577,7 @@
hri_sercomusart_write_INTEN_ERROR_bit(device->hw, state);
}
 }
-
+#include 
 /**
  * \internal Sercom interrupt handler
  *
@@ -591,6 +591,12 @@
hri_sercomusart_clear_INTEN_DRE_bit(hw);
device->usart_cb.tx_byte_sent(device);
} else if (hri_sercomusart_get_interrupt_TXC_bit(hw) && 
hri_sercomusart_get_INTEN_TXC_bit(hw)) {
+#if 0
+// tx byte last edge <-> txc irq delay
+   gpio_set_pin_level(PIN_PB12, true);
+   delay_us(1);
+   gpio_set_pin_level(PIN_PB12, false);
+#endif
hri_sercomusart_clear_INTEN_TXC_bit(hw);
device->usart_cb.tx_done_cb(device);
} else if (hri_sercomusart_get_interrupt_RXC_bit(hw)) {
@@ -600,8 +606,20 @@
hri_sercomusart_clear_STATUS_reg(hw, 
SERCOM_USART_STATUS_MASK);
return;
}
+#if 0
+// rx byte last edge <-> rxc irq delay
+   gpio_set_pin_level(PIN_PB12, true);
+   delay_us(1);
+   gpio_set_pin_level(PIN_PB12, false);
+#endif

device->usart_cb.rx_done_cb(device, 
hri_sercomusart_read_DATA_reg(hw));
+#if 0
+// rx byte last edge <-> rxc irq end delay
+   gpio_set_pin_level(PIN_PB12, true);
+   delay_us(1);
+   gpio_set_pin_level(PIN_PB12, false);
+#endif
} else if (hri_sercomusart_get_interrupt_ERROR_bit(hw)) {
uint32_t status;

diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index a1b84b7..54616af 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -506,6 +506,17 @@
}
submit_next_out();
CRITICAL_SECTION_LEAVE()
+#if 0
+   /* CAN_RX */
+   gpio_set_pin_function(PIN_PB12, GPIO_PIN_FUNCTION_OFF);
+   gpio_set_pin_direction(PIN_PB12, GPIO_DIRECTION_OUT);
+   gpio_set_pin_level(PIN_PB12, false);
+
+   /* CAN_TX */
+   gpio_set_pin_function(PIN_PB13, GPIO_PIN_FUNCTION_OFF);
+   gpio_set_pin_direction(PIN_PB13, GPIO_DIRECTION_OUT);
+   gpio_set_pin_level(PIN_PB13, false);
+#endif

 // command_print_prompt();
while (true) { // main loop

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16278
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I5f2c174076b5599dcb56f887330de27f470aeffc
Gerrit-Change-Number: 16278
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: move iso7816_3 to common dir

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16272 )


Change subject: move iso7816_3 to common dir
..

move iso7816_3 to common dir

Change-Id: Id8cfc9247988ae999f5544d936d67f12e3902b92
---
R ccid_common/iso7816_3.c
R ccid_common/iso7816_3.h
M sysmoOCTSIM/gcc/Makefile
3 files changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/72/16272/1

diff --git a/sysmoOCTSIM/iso7816_3.c b/ccid_common/iso7816_3.c
similarity index 100%
rename from sysmoOCTSIM/iso7816_3.c
rename to ccid_common/iso7816_3.c
diff --git a/sysmoOCTSIM/iso7816_3.h b/ccid_common/iso7816_3.h
similarity index 100%
rename from sysmoOCTSIM/iso7816_3.h
rename to ccid_common/iso7816_3.h
diff --git a/sysmoOCTSIM/gcc/Makefile b/sysmoOCTSIM/gcc/Makefile
index 4840fea..95a582f 100644
--- a/sysmoOCTSIM/gcc/Makefile
+++ b/sysmoOCTSIM/gcc/Makefile
@@ -84,6 +84,7 @@
ccid_common/ccid_proto.o \
ccid_common/ccid_device.o \
ccid_common/iso7816_fsm.o \
+   ccid_common/iso7816_3.o \
ccid_common/cuart.o \
ccid_common/ccid_slot_fsm.o \
cuart_driver_asf4_usart_async.o \
@@ -123,7 +124,6 @@
hpl/sercom/hpl_sercom.o \
hpl/usb/hpl_usb.o \
i2c_bitbang.o \
-   iso7816_3.o \
libosmo_emb.o \
main.o \
manual_test.o \

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16272
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Id8cfc9247988ae999f5544d936d67f12e3902b92
Gerrit-Change-Number: 16272
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: fsm completion event handling from main loop

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16284 )


Change subject: fsm completion event handling from main loop
..

fsm completion event handling from main loop

The main loop will now poll for finished/failed transactions and handle
them, this was previously handled during the last rx interrupt of a
transaction, which was bad for timing. This does also fix malloc/free
while handling interrupts.

Change-Id: I055110720089e20e65db592eccc3ce4d618e8c63
---
M ccid_common/ccid_device.h
M ccid_common/ccid_slot_fsm.c
M ccid_common/iso7816_fsm.c
M sysmoOCTSIM/main.c
4 files changed, 68 insertions(+), 21 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/84/16284/1

diff --git a/ccid_common/ccid_device.h b/ccid_common/ccid_device.h
index 38a71db..f364f72 100644
--- a/ccid_common/ccid_device.h
+++ b/ccid_common/ccid_device.h
@@ -57,6 +57,8 @@
struct ccid_pars_decoded proposed_pars;
/* default parameters; applied on ResetParameters */
const struct ccid_pars_decoded *default_pars;
+   volatile uint32_t event;
+   volatile void* event_data;
 };

 /* CCID operations provided by USB transport layer */
@@ -86,6 +88,7 @@
  const struct ccid_pars_decoded *pars_dec);
int (*set_rate_and_clock)(struct ccid_slot *cs, uint32_t freq_hz, 
uint32_t rate_bps);
void (*icc_set_insertion_status)(struct ccid_slot *cs, bool present);
+   int (*handle_fsm_events)(struct ccid_slot *cs, bool enable);
 };

 /* An instance of CCID (i.e. a card reader device) */
diff --git a/ccid_common/ccid_slot_fsm.c b/ccid_common/ccid_slot_fsm.c
index d2aec26..9be31d6 100644
--- a/ccid_common/ccid_slot_fsm.c
+++ b/ccid_common/ccid_slot_fsm.c
@@ -110,34 +110,76 @@
 {
struct iso_fsm_slot *ss = iso7816_fsm_get_user_priv(fi);
struct ccid_slot *cs = ss->cs;
+
+   switch (event) {
+   case ISO7816_E_ATR_DONE_IND:
+   case ISO7816_E_ATR_ERR_IND:
+   case ISO7816_E_TPDU_DONE_IND:
+   case ISO7816_E_TPDU_FAILED_IND:
+   case ISO7816_E_PPS_DONE_IND:
+   case ISO7816_E_PPS_FAILED_IND:
+   cs->event_data = data;
+   asm volatile("dmb st": : :"memory");
+   cs->event = event;
+   break;
+   default:
+   LOGPCS(cs, LOGL_NOTICE, "%s(event=%d, cause=%d, data=%p) 
unhandled\n",
+   __func__, event, cause, data);
+   break;
+   }
+}
+
+static int iso_handle_fsm_events(struct ccid_slot *cs, bool enable){
+   struct iso_fsm_slot *ss = ccid_slot2iso_fsm_slot(cs);
struct msgb *tpdu, *resp;
+   volatile uint32_t event = cs->event;
+   volatile void * volatile data = cs->event_data;
+
+   if(!event)
+   return 0;
+   if(event && !data)
+   return 0;

switch (event) {
case ISO7816_E_ATR_DONE_IND:
tpdu = data;
-   LOGPCS(cs, LOGL_DEBUG, "%s(event=%d, cause=%d, data=%s)\n", 
__func__, event, cause,
+   LOGPCS(cs, LOGL_DEBUG, "%s(event=%d, data=%s)\n", __func__, 
event,
msgb_hexdump(tpdu));
resp = ccid_gen_data_block(cs, ss->seq, CCID_CMD_STATUS_OK, 0,
   msgb_data(tpdu), msgb_length(tpdu));
ccid_slot_send_unbusy(cs, resp);
/* Don't free "TPDU" here, as the ATR should survive */
+   cs->event = 0;
+   break;
+   case ISO7816_E_ATR_ERR_IND:
+   tpdu = data;
+   LOGPCS(cs, LOGL_DEBUG, "%s(event=%d, data=%s)\n", __func__, 
event,
+   msgb_hexdump(tpdu));
+   resp = ccid_gen_data_block(cs, ss->seq, CCID_CMD_STATUS_FAILED, 
CCID_ERR_ICC_MUTE,
+  msgb_data(tpdu), msgb_length(tpdu));
+   ccid_slot_send_unbusy(cs, resp);
+   /* Don't free "TPDU" here, as the ATR should survive */
+   cs->event = 0;
+   break;
break;
case ISO7816_E_TPDU_DONE_IND:
tpdu = data;
-   LOGPCS(cs, LOGL_DEBUG, "%s(event=%d, cause=%d, data=%s)\n", 
__func__, event, cause,
+   LOGPCS(cs, LOGL_DEBUG, "%s(event=%d, data=%s)\n", __func__, 
event,
msgb_hexdump(tpdu));
resp = ccid_gen_data_block(cs, ss->seq, CCID_CMD_STATUS_OK, 0, 
msgb_l2(tpdu), msgb_l2len(tpdu));
ccid_slot_send_unbusy(cs, resp);
msgb_free(tpdu);
+   cs->event = 0;
break;
case ISO7816_E_TPDU_FAILED_IND:
tpdu = data;
-   LOGPCS(cs, LOGL_DEBUG, "%s(event=%d, cause=%d, data=%s)\n", 
__func__, event, cause,
+   LOGPCS(cs, LOGL_DEBUG, "%s(event=%d, data=%s)\n", __func__, 
event,

Change in osmo-ccid-firmware[master]: increase the debug uart buffer size

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16276 )


Change subject: increase the debug uart buffer size
..

increase the debug uart buffer size

printing to the buffer is faster than getting the data out, so let's
increase it a bit to drop less information

Change-Id: I343b03d5b06962b90f0c1aaceda03aa871a2f98b
---
M sysmoOCTSIM/driver_init.c
1 file changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/76/16276/1

diff --git a/sysmoOCTSIM/driver_init.c b/sysmoOCTSIM/driver_init.c
index c373dc2..7071ea5 100644
--- a/sysmoOCTSIM/driver_init.c
+++ b/sysmoOCTSIM/driver_init.c
@@ -33,7 +33,7 @@
 #define SIM6_BUFFER_SIZE 512

 /*! The buffer size for USART */
-#define UART_DEBUG_BUFFER_SIZE 256
+#define UART_DEBUG_BUFFER_SIZE 4096

 struct usart_async_descriptor SIM0;
 struct usart_async_descriptor SIM1;

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16276
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I343b03d5b06962b90f0c1aaceda03aa871a2f98b
Gerrit-Change-Number: 16276
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: switching rx/tx is too slow, and not necessary

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16280 )


Change subject: switching rx/tx is too slow, and not necessary
..

switching rx/tx is too slow, and not necessary

Change-Id: Ic91b3e183ba451b4e327e407aae0497273652f56
---
M sysmoOCTSIM/cuart_driver_asf4_usart_async.c
1 file changed, 1 insertion(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/80/16280/1

diff --git a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c 
b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
index 21ab5a4..a0b3821 100644
--- a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
+++ b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
@@ -352,12 +352,9 @@
break;
case CUART_CTL_RX:
if (arg){
-   sercom->USART.CTRLB.bit.RXEN = 1;
-   sercom->USART.CTRLB.bit.TXEN = 0;
+   /* no op */
} else {
delay_us(cuart->u.asf4.extrawait_after_rx);
-   sercom->USART.CTRLB.bit.RXEN = 0;
-   sercom->USART.CTRLB.bit.TXEN = 1;
}
break;
case CUART_CTL_RST:

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16280
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ic91b3e183ba451b4e327e407aae0497273652f56
Gerrit-Change-Number: 16280
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: add some volatility to debug missing state changes

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16281 )


Change subject: add some volatility to debug missing state changes
..

add some volatility to debug missing state changes

Change-Id: I2e12e32ad27b03d73ba3533903c34abc2fcce37a
---
M sysmoOCTSIM/main.c
1 file changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/81/16281/1

diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index 54616af..02b7b09 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -101,7 +101,7 @@
/* bit-mask of card-insert status, as determined from NCN8025 IRQ 
output */
uint8_t card_insert_mask;
 };
-static struct ccid_state g_ccid_s;
+static volatile struct ccid_state g_ccid_s;

 static void ccid_out_read_compl(const uint8_t ep, enum usb_xfer_code code, 
uint32_t transferred);
 static void ccid_in_write_compl(const uint8_t ep, enum usb_xfer_code code, 
uint32_t transferred);

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16281
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I2e12e32ad27b03d73ba3533903c34abc2fcce37a
Gerrit-Change-Number: 16281
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: pps warning

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16286 )


Change subject: pps warning
..

pps warning

Change-Id: Ia125b7983e81342af224bc6e8771d8be4c4bfa42
---
M ccid_common/ccid_slot_fsm.c
1 file changed, 7 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/86/16286/1

diff --git a/ccid_common/ccid_slot_fsm.c b/ccid_common/ccid_slot_fsm.c
index d7740fe..fef1515 100644
--- a/ccid_common/ccid_slot_fsm.c
+++ b/ccid_common/ccid_slot_fsm.c
@@ -188,6 +188,13 @@
uint8_t D = iso7816_3_di_table[cs->proposed_pars.di];
uint32_t fmax = iso7816_3_fmax_table[cs->proposed_pars.fi];

+   /* 7816-3 5.2.3
+* No  information  shall  be  exchanged  when  switching  the
+* frequency  value.  Two  different  times  are  recommended
+* for switching the frequency value, either
+* - after ATR while card is idle
+* - after PPS while card is idle
+*/
card_uart_ctrl(ss->cuart, CUART_CTL_CLOCK_FREQ, fmax);
card_uart_ctrl(ss->cuart, CUART_CTL_FD, F/D);
card_uart_ctrl(ss->cuart, CUART_CTL_WTIME, 
cs->proposed_pars.t0.waiting_integer);

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16286
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ia125b7983e81342af224bc6e8771d8be4c4bfa42
Gerrit-Change-Number: 16286
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: sercom config for t1

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16265 )


Change subject: sercom config for t1
..

sercom config for t1

t0 doesn't work

Change-Id: Ie6cb7ec51036f1de15c83b59d130f3cb85309594
---
M sysmoOCTSIM/config/hpl_sercom_config.h
1 file changed, 14 insertions(+), 14 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/65/16265/1

diff --git a/sysmoOCTSIM/config/hpl_sercom_config.h 
b/sysmoOCTSIM/config/hpl_sercom_config.h
index beac040..bb2bbff 100644
--- a/sysmoOCTSIM/config/hpl_sercom_config.h
+++ b/sysmoOCTSIM/config/hpl_sercom_config.h
@@ -52,7 +52,7 @@
 //  Number of stop bits in USART frame
 //  usart_stop_bit
 #ifndef CONF_SERCOM_0_USART_SBMODE
-#define CONF_SERCOM_0_USART_SBMODE 0
+#define CONF_SERCOM_0_USART_SBMODE 1
 #endif

 //  Baud rate <1-300>
@@ -70,7 +70,7 @@
 //  Define ISO7816 protocol type as 0.
 //  usart_iso7816_type
 #ifndef CONF_SERCOM_0_USART_ISO7816_PROTOCOL_T
-#define CONF_SERCOM_0_USART_ISO7816_PROTOCOL_T 0x1
+#define CONF_SERCOM_0_USART_ISO7816_PROTOCOL_T 0x0
 #endif

 //  ISO7816 Inhibit Not Acknowledge
@@ -324,7 +324,7 @@
 //  Number of stop bits in USART frame
 //  usart_stop_bit
 #ifndef CONF_SERCOM_1_USART_SBMODE
-#define CONF_SERCOM_1_USART_SBMODE 0
+#define CONF_SERCOM_1_USART_SBMODE 1
 #endif

 //  Baud rate <1-300>
@@ -342,7 +342,7 @@
 //  Define ISO7816 protocol type as 0.
 //  usart_iso7816_type
 #ifndef CONF_SERCOM_1_USART_ISO7816_PROTOCOL_T
-#define CONF_SERCOM_1_USART_ISO7816_PROTOCOL_T 0x1
+#define CONF_SERCOM_1_USART_ISO7816_PROTOCOL_T 0x0
 #endif

 //  ISO7816 Inhibit Not Acknowledge
@@ -596,7 +596,7 @@
 //  Number of stop bits in USART frame
 //  usart_stop_bit
 #ifndef CONF_SERCOM_2_USART_SBMODE
-#define CONF_SERCOM_2_USART_SBMODE 0
+#define CONF_SERCOM_2_USART_SBMODE 1
 #endif

 //  Baud rate <1-300>
@@ -614,7 +614,7 @@
 //  Define ISO7816 protocol type as 0.
 //  usart_iso7816_type
 #ifndef CONF_SERCOM_2_USART_ISO7816_PROTOCOL_T
-#define CONF_SERCOM_2_USART_ISO7816_PROTOCOL_T 0x1
+#define CONF_SERCOM_2_USART_ISO7816_PROTOCOL_T 0x0
 #endif

 //  ISO7816 Inhibit Not Acknowledge
@@ -868,7 +868,7 @@
 //  Number of stop bits in USART frame
 //  usart_stop_bit
 #ifndef CONF_SERCOM_3_USART_SBMODE
-#define CONF_SERCOM_3_USART_SBMODE 0
+#define CONF_SERCOM_3_USART_SBMODE 1
 #endif

 //  Baud rate <1-300>
@@ -886,7 +886,7 @@
 //  Define ISO7816 protocol type as 0.
 //  usart_iso7816_type
 #ifndef CONF_SERCOM_3_USART_ISO7816_PROTOCOL_T
-#define CONF_SERCOM_3_USART_ISO7816_PROTOCOL_T 0x1
+#define CONF_SERCOM_3_USART_ISO7816_PROTOCOL_T 0x0
 #endif

 //  ISO7816 Inhibit Not Acknowledge
@@ -1140,7 +1140,7 @@
 //  Number of stop bits in USART frame
 //  usart_stop_bit
 #ifndef CONF_SERCOM_4_USART_SBMODE
-#define CONF_SERCOM_4_USART_SBMODE 0
+#define CONF_SERCOM_4_USART_SBMODE 1
 #endif

 //  Baud rate <1-300>
@@ -1158,7 +1158,7 @@
 //  Define ISO7816 protocol type as 0.
 //  usart_iso7816_type
 #ifndef CONF_SERCOM_4_USART_ISO7816_PROTOCOL_T
-#define CONF_SERCOM_4_USART_ISO7816_PROTOCOL_T 0x1
+#define CONF_SERCOM_4_USART_ISO7816_PROTOCOL_T 0x0
 #endif

 //  ISO7816 Inhibit Not Acknowledge
@@ -1412,7 +1412,7 @@
 //  Number of stop bits in USART frame
 //  usart_stop_bit
 #ifndef CONF_SERCOM_5_USART_SBMODE
-#define CONF_SERCOM_5_USART_SBMODE 0
+#define CONF_SERCOM_5_USART_SBMODE 1
 #endif

 //  Baud rate <1-300>
@@ -1430,7 +1430,7 @@
 //  Define ISO7816 protocol type as 0.
 //  usart_iso7816_type
 #ifndef CONF_SERCOM_5_USART_ISO7816_PROTOCOL_T
-#define CONF_SERCOM_5_USART_ISO7816_PROTOCOL_T 0x1
+#define CONF_SERCOM_5_USART_ISO7816_PROTOCOL_T 0x0
 #endif

 //  ISO7816 Inhibit Not Acknowledge
@@ -1684,7 +1684,7 @@
 //  Number of stop bits in USART frame
 //  usart_stop_bit
 #ifndef CONF_SERCOM_6_USART_SBMODE
-#define CONF_SERCOM_6_USART_SBMODE 0
+#define CONF_SERCOM_6_USART_SBMODE 1
 #endif

 //  Baud rate <1-300>
@@ -1702,7 +1702,7 @@
 //  Define ISO7816 protocol type as 0.
 //  usart_iso7816_type
 #ifndef CONF_SERCOM_6_USART_ISO7816_PROTOCOL_T
-#define CONF_SERCOM_6_USART_ISO7816_PROTOCOL_T 0x1
+#define CONF_SERCOM_6_USART_ISO7816_PROTOCOL_T 0x0
 #endif

 //  ISO7816 Inhibit Not Acknowledge

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16265
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ie6cb7ec51036f1de15c83b59d130f3cb85309594
Gerrit-Change-Number: 16265
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: debug code to use the DWT unit

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16277 )


Change subject: debug code to use the DWT unit
..

debug code to use the DWT unit

Change-Id: Ide6e34425e77425b260139ac1b4c528953a994f4
---
M sysmoOCTSIM/main.c
1 file changed, 23 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/77/16277/1

diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index 959e7eb..a1b84b7 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -442,6 +442,29 @@
char sernr_buf[16*2+1];
char rstcause_buf[RSTCAUSE_STR_SIZE];

+#if 0
+CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk ; //| /* tracing*/
+CoreDebug_DEMCR_MON_EN_Msk; /* mon interupt catcher */
+
+
+DWT->COMP0 = 0x40003028; /* sercom 0 data */
+//DWT->COMP0 = 0x40003428; /* sercom 1 data */
+DWT->MASK0 = 0; /* 0 */
+DWT->FUNCTION0 = 0; /* has to be 0 for linked address */
+
+DWT->COMP1 = 0xa5; /* value */
+DWT->MASK1 = 0; /* match all bits */
+DWT->FUNCTION1 =(0b10 << DWT_FUNCTION_DATAVSIZE_Pos) |  /* DATAVSIZE 10 - 
dword */
+#if 1
+(0 << DWT_FUNCTION_DATAVADDR0_Pos) | /* Data Match linked addr pointer in 
COMP0 */
+#else
+(1 << DWT_FUNCTION_DATAVADDR0_Pos) | /* Data Match on any addr -> own number */
+#endif
+(1 << DWT_FUNCTION_DATAVMATCH_Pos) | /* DATAVMATCH Enable data comparation */
+(0b0111 << DWT_FUNCTION_FUNCTION_Pos);  /* generate a watchpoint event on rw */
+
+#endif
+
atmel_start_init();
get_chip_unique_serial_str(sernr_buf, sizeof(sernr_buf));
get_rstcause_str(rstcause_buf);

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16277
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ide6e34425e77425b260139ac1b4c528953a994f4
Gerrit-Change-Number: 16277
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: cuart icc clock freq and divider setting support

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16273 )


Change subject: cuart icc clock freq and divider setting support
..

cuart icc clock freq and divider setting support

Change-Id: I9c99c68511d3972513348ee6be5e7bb3b3a5f99e
---
M ccid_common/cuart.h
M sysmoOCTSIM/cuart_driver_asf4_usart_async.c
M sysmoOCTSIM/ncn8025.c
M sysmoOCTSIM/ncn8025.h
4 files changed, 43 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/73/16273/1

diff --git a/ccid_common/cuart.h b/ccid_common/cuart.h
index 5e397ab..6c53481 100644
--- a/ccid_common/cuart.h
+++ b/ccid_common/cuart.h
@@ -25,8 +25,10 @@
CUART_CTL_RX,   /* enable/disable receiver */
CUART_CTL_POWER,/* enable/disable ICC power */
CUART_CTL_CLOCK,/* enable/disable ICC clock */
+   CUART_CTL_CLOCK_FREQ, /* set ICC clock frequency (hz)*/
CUART_CTL_RST,  /* enable/disable ICC reset */
CUART_CTL_WTIME,/* set the waiting time (in etu) */
+   CUART_CTL_FD,
 };

 struct card_uart;
@@ -95,6 +97,8 @@
struct {
struct usart_async_descriptor *usa_pd;
uint8_t slot_nr;
+   /* in us, required, no delay breaks _rx_ */
+   uint32_t extrawait_after_rx;
} asf4;
} u;
 };
diff --git a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c 
b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
index f9856f3..a8f8044 100644
--- a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
+++ b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
@@ -289,6 +289,8 @@
cuart->u.asf4.usa_pd = usa_pd;
cuart->u.asf4.slot_nr = slot_nr;

+   /* in us, 20Mhz with default ncn8025 divider 8, F=372, D=1*/
+   cuart->u.asf4.extrawait_after_rx = 1./(20./8/372);

usart_async_register_callback(usa_pd, USART_ASYNC_RXC_CB, 
SIM_rx_cb[slot_nr]);
usart_async_register_callback(usa_pd, USART_ASYNC_TXC_CB, 
SIM_tx_cb[slot_nr]);
@@ -338,6 +340,8 @@
return io_read(&usa_pd->io, data, len);
 }

+#include "ccid_device.h"
+#include "iso7816_3.h"
 static int asf4_usart_ctrl(struct card_uart *cuart, enum card_uart_ctl ctl, 
int arg)
 {
struct ncn8025_settings settings;
@@ -349,7 +353,7 @@
sercom->USART.CTRLB.bit.RXEN = 1;
sercom->USART.CTRLB.bit.TXEN = 0;
} else {
-   delay_us(100);
+   delay_us(cuart->u.asf4.extrawait_after_rx);
sercom->USART.CTRLB.bit.RXEN = 0;
sercom->USART.CTRLB.bit.TXEN = 1;
}
@@ -361,22 +365,47 @@
usart_async_flush_rx_buffer(cuart->u.asf4.usa_pd);
break;
case CUART_CTL_POWER:
-   ncn8025_get(cuart->u.asf4.slot_nr, &settings);
-   settings.cmdvcc = arg ? true : false;
-   settings.led = arg ? true : false;
-   settings.vsel = SIM_VOLT_5V0;
+   /* in us, 20Mhz with default ncn8025 divider 8, F=372, D=1*/
+   cuart->u.asf4.extrawait_after_rx = 1./(20./8/372);

// set USART baud rate to match the interface (f = 2.5 MHz) and 
card default settings (Fd = 372, Dd = 1)
if(arg)
slot_set_isorate(cuart->u.asf4.slot_nr, SIM_CLKDIV_8, 
ISO7816_3_DEFAULT_FD, ISO7816_3_DEFAULT_DD);

+   ncn8025_get(cuart->u.asf4.slot_nr, &settings);
+   settings.cmdvcc = arg ? true : false;
+   settings.led = arg ? true : false;
+   settings.vsel = SIM_VOLT_5V0;
ncn8025_set(cuart->u.asf4.slot_nr, &settings);
+
break;
case CUART_CTL_WTIME:
/* no driver-specific handling of this */
break;
case CUART_CTL_CLOCK:
-   /* FIXME */
+   /* no clock stop support */
+   break;
+   case CUART_CTL_CLOCK_FREQ:
+   ncn8025_get(cuart->u.asf4.slot_nr, &settings);
+
+   /* 2,5/5/10/20 supported by dividers */
+   enum ncn8025_sim_clkdiv clkdiv = SIM_CLKDIV_1;
+   if(arg < 2000)
+   clkdiv = SIM_CLKDIV_2;
+   if(arg < 1000)
+   clkdiv = SIM_CLKDIV_4;
+   if(arg < 500)
+   clkdiv = SIM_CLKDIV_8;
+   settings.clkdiv = clkdiv;
+   ncn8025_set(cuart->u.asf4.slot_nr, &settings);
+   break;
+   case CUART_CTL_FD:
+   ncn8025_get(cuart->u.asf4.slot_nr, &settings);
+   uint8_t divider = ncn8025_div_val[settings.clkdiv];
+   uint32_t baudrate = (20e6/divider)/arg;
+   cuart->u.asf4.extrawait_after_rx = 1./baudrate * 1000 * 1000;
+

Change in osmo-ccid-firmware[master]: better ccid error handling, fix buffer leaks

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16282 )


Change subject: better ccid error handling, fix buffer leaks
..

better ccid error handling, fix buffer leaks

Change-Id: Ib8b8524809e12608a7ade79ce7d7c3ced16eeb57
---
M ccid_common/ccid_device.c
M ccid_common/ccid_slot_fsm.c
M ccid_common/iso7816_fsm.c
3 files changed, 30 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/82/16282/1

diff --git a/ccid_common/ccid_device.c b/ccid_common/ccid_device.c
index 11edd3e..b14f194 100644
--- a/ccid_common/ccid_device.c
+++ b/ccid_common/ccid_device.c
@@ -475,14 +475,25 @@
const struct ccid_header *ch = (const struct ccid_header *) u;
uint8_t seq = u->reset_parameters.hdr.bSeq;
struct msgb *resp;
+   int rc;

/* copy default parameters from somewhere */
/* FIXME: T=1 */
-   cs->ci->slot_ops->set_params(cs, seq, CCID_PROTOCOL_NUM_T0, 
cs->default_pars);
-   cs->pars = *cs->default_pars;

-   resp = ccid_gen_parameters_t0(cs, seq, CCID_CMD_STATUS_OK, 0);
-   return ccid_slot_send_unbusy(cs, resp);
+   /* validate parameters; abort if they are not supported */
+   rc = cs->ci->slot_ops->set_params(cs, seq, CCID_PROTOCOL_NUM_T0, 
cs->default_pars);
+   if (rc < 0) {
+   resp = ccid_gen_parameters_t0(cs, seq, CCID_CMD_STATUS_FAILED, 
-rc);
+   goto out;
+   }
+
+   msgb_free(msg);
+   /* busy, tdpu like callback */
+   return 1;
+out:
+   msgb_free(msg);
+   ccid_slot_send_unbusy(cs, resp);
+   return 1;
 }

 /* Section 6.1.7 */
@@ -523,10 +534,14 @@
resp = ccid_gen_parameters_t0(cs, seq, CCID_CMD_STATUS_FAILED, 
-rc);
goto out;
}
+
+   msgb_free(msg);
/* busy, tdpu like callback */
return 1;
 out:
-   return ccid_slot_send_unbusy(cs, resp);
+   msgb_free(msg);
+   ccid_slot_send_unbusy(cs, resp);
+   return 1;
 }

 /* Section 6.1.8 */
@@ -682,6 +697,15 @@
return ccid_send(ci, resp);
}

+   if(!cs->icc_present) {
+   LOGPCS(cs, LOGL_ERROR, "No icc present, but another cmd 
received\n");
+   /* FIXME: ABORT logic as per section 5.3.1 of CCID Spec v1.1 */
+   resp = gen_err_resp(ch->bMessageType, ch->bSlot, 
get_icc_status(cs), ch->bSeq,
+   CCID_ERR_ICC_MUTE);
+   msgb_free(msg);
+   return ccid_send(ci, resp);
+   }
+
LOGPCS(cs, LOGL_DEBUG, "Rx CCID(OUT) %s %s\n",
get_value_string(ccid_msg_type_vals, ch->bMessageType), 
msgb_hexdump(msg));

diff --git a/ccid_common/ccid_slot_fsm.c b/ccid_common/ccid_slot_fsm.c
index 8d38f29..d2aec26 100644
--- a/ccid_common/ccid_slot_fsm.c
+++ b/ccid_common/ccid_slot_fsm.c
@@ -179,9 +179,6 @@
struct iso_fsm_slot *ss = ccid_slot2iso_fsm_slot(cs);
struct msgb *tpdu;

-   if(!cs->icc_present)
-   return -CCID_ERR_ICC_MUTE;
-
ss->seq = xfb->hdr.bSeq;

/* must be '0' for TPDU level exchanges or for short APDU */
diff --git a/ccid_common/iso7816_fsm.c b/ccid_common/iso7816_fsm.c
index 623193f..3778dcc 100644
--- a/ccid_common/iso7816_fsm.c
+++ b/ccid_common/iso7816_fsm.c
@@ -293,6 +293,7 @@
ip->user_cb(fi, event, 0, atr);
break;
case ISO7816_E_ATR_ERR_IND:
+   atr = data;
osmo_fsm_inst_state_chg(fi, ISO7816_S_RESET, 0, 0);
ip->user_cb(fi, event, 0, atr);
break;

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16282
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ib8b8524809e12608a7ade79ce7d7c3ced16eeb57
Gerrit-Change-Number: 16282
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: attempt at handling card insertion/removal

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16275 )


Change subject: attempt at handling card insertion/removal
..

attempt at handling card insertion/removal

Change-Id: I88130de7f889811425c0a2ca4063ea8822c83f66
---
M ccid_common/ccid_device.c
M ccid_common/ccid_device.h
M ccid_common/ccid_slot_fsm.c
M ccid_common/iso7816_fsm.c
M ccid_common/iso7816_fsm.h
M sysmoOCTSIM/main.c
6 files changed, 89 insertions(+), 31 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/75/16275/1

diff --git a/ccid_common/ccid_device.c b/ccid_common/ccid_device.c
index c67c52e..11edd3e 100644
--- a/ccid_common/ccid_device.c
+++ b/ccid_common/ccid_device.c
@@ -438,9 +438,20 @@
 {
const union ccid_pc_to_rdr *u = msgb_ccid_out(msg);
const struct ccid_header *ch = (const struct ccid_header *) u;
+   struct msgb *resp;
+   int rc;

/* handle this asynchronously */
-   cs->ci->slot_ops->xfr_block_async(cs, msg, &u->xfr_block);
+   rc = cs->ci->slot_ops->xfr_block_async(cs, msg, &u->xfr_block);
+   if (rc < 0) {
+   msgb_trim(msg, sizeof(struct ccid_rdr_to_pc_data_block));
+   resp = ccid_gen_data_block(cs, u->xfr_block.hdr.bSeq, 
CCID_CMD_STATUS_FAILED, -rc, 0, 0);
+   goto out;
+   }
+   /* busy */
+   return 1;
+out:
+   ccid_slot_send_unbusy(cs, resp);
return 1;
 }

diff --git a/ccid_common/ccid_device.h b/ccid_common/ccid_device.h
index 8390783..38a71db 100644
--- a/ccid_common/ccid_device.h
+++ b/ccid_common/ccid_device.h
@@ -78,13 +78,14 @@

void (*icc_power_on_async)(struct ccid_slot *cs, struct msgb *msg,
   const struct ccid_pc_to_rdr_icc_power_on 
*ipo);
-   void (*xfr_block_async)(struct ccid_slot *cs, struct msgb *msg,
+   int (*xfr_block_async)(struct ccid_slot *cs, struct msgb *msg,
const struct ccid_pc_to_rdr_xfr_block *xfb);
void (*set_power)(struct ccid_slot *cs, bool enable);
void (*set_clock)(struct ccid_slot *cs, enum ccid_clock_command cmd);
int (*set_params)(struct ccid_slot *cs, uint8_t seq, enum 
ccid_protocol_num proto,
  const struct ccid_pars_decoded *pars_dec);
int (*set_rate_and_clock)(struct ccid_slot *cs, uint32_t freq_hz, 
uint32_t rate_bps);
+   void (*icc_set_insertion_status)(struct ccid_slot *cs, bool present);
 };

 /* An instance of CCID (i.e. a card reader device) */
diff --git a/ccid_common/ccid_slot_fsm.c b/ccid_common/ccid_slot_fsm.c
index 8bdcfd5..8d38f29 100644
--- a/ccid_common/ccid_slot_fsm.c
+++ b/ccid_common/ccid_slot_fsm.c
@@ -66,6 +66,23 @@
/* do nothing; real hardware would update the slot related state here */
 }

+static void iso_fsm_slot_icc_set_insertion_status(struct ccid_slot *cs, bool 
present) {
+   struct iso_fsm_slot *ss = ccid_slot2iso_fsm_slot(cs);
+
+   if(present == cs->icc_present)
+   return;
+
+   cs->icc_present = present;
+
+   if (!present) {
+   osmo_fsm_inst_dispatch(ss->fi, ISO7816_E_CARD_REMOVAL, NULL);
+   card_uart_ctrl(ss->cuart, CUART_CTL_RST, true);
+   card_uart_ctrl(ss->cuart, CUART_CTL_POWER, false);
+   cs->icc_powered = false;
+   cs->cmd_busy = false;
+   }
+}
+
 static void iso_fsm_slot_icc_power_on_async(struct ccid_slot *cs, struct msgb 
*msg,
const struct 
ccid_pc_to_rdr_icc_power_on *ipo)
 {
@@ -113,6 +130,15 @@
ccid_slot_send_unbusy(cs, resp);
msgb_free(tpdu);
break;
+   case ISO7816_E_TPDU_FAILED_IND:
+   tpdu = data;
+   LOGPCS(cs, LOGL_DEBUG, "%s(event=%d, cause=%d, data=%s)\n", 
__func__, event, cause,
+   msgb_hexdump(tpdu));
+   /* FIXME: other error causes than card removal?*/
+   resp = ccid_gen_data_block(cs, ss->seq, CCID_CMD_STATUS_FAILED, 
CCID_ERR_ICC_MUTE, msgb_l2(tpdu), 0);
+   ccid_slot_send_unbusy(cs, resp);
+   msgb_free(tpdu);
+   break;
case ISO7816_E_PPS_DONE_IND:
tpdu = data;
/* pps was successful, so we know these values are fine */
@@ -147,12 +173,15 @@
}
 }

-static void iso_fsm_slot_xfr_block_async(struct ccid_slot *cs, struct msgb 
*msg,
+static int iso_fsm_slot_xfr_block_async(struct ccid_slot *cs, struct msgb *msg,
const struct ccid_pc_to_rdr_xfr_block *xfb)
 {
struct iso_fsm_slot *ss = ccid_slot2iso_fsm_slot(cs);
struct msgb *tpdu;

+   if(!cs->icc_present)
+   return -CCID_ERR_ICC_MUTE;
+
ss->seq = xfb->hdr.bSeq;

/* must be '0' for TPDU level exchanges or for short APDU */
@@ -171,6 +200,7 @@
  

Change in osmo-ccid-firmware[master]: no logging, no memory pool

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16270 )


Change subject: no logging, no memory pool
..

no logging, no memory pool

Change-Id: Iaf5123ab0340efec7b8e11e689f529f2e95e31ca
---
M sysmoOCTSIM/atmel_start.c
M sysmoOCTSIM/libosmo_emb.c
M sysmoOCTSIM/main.c
3 files changed, 15 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/70/16270/1

diff --git a/sysmoOCTSIM/atmel_start.c b/sysmoOCTSIM/atmel_start.c
index bee1ed2..6670364 100644
--- a/sysmoOCTSIM/atmel_start.c
+++ b/sysmoOCTSIM/atmel_start.c
@@ -14,6 +14,6 @@
system_init();
dma_memory_init();
dma_memory_register_callback(DMA_MEMORY_COMPLETE_CB, 
M2M_DMA_complete_cb);
-   stdio_redirect_init();
+// stdio_redirect_init();
usb_init();
 }
diff --git a/sysmoOCTSIM/libosmo_emb.c b/sysmoOCTSIM/libosmo_emb.c
index 1914568..a12c490 100644
--- a/sysmoOCTSIM/libosmo_emb.c
+++ b/sysmoOCTSIM/libosmo_emb.c
@@ -41,43 +41,43 @@
[DUSB] = {
.name = "USB",
.description = "USB Transport",
-   .enabled = 1,
+   .enabled = 0,
.loglevel = LOGL_NOTICE,
},
[DCCID] = {
.name = "CCID",
.description = "USB-CCID Protocol",
-   .enabled = 1,
+   .enabled = 0,
.loglevel = LOGL_DEBUG,
},
[DISO7816] = {
.name = "ISO7816",
.description = "ISO7816-3 State machines",
-   .enabled = 1,
+   .enabled = 0,
.loglevel = LOGL_DEBUG,
},
[DATR] = {
.name = "ATR",
.description = "ATR (Answer To Reset) FSM",
-   .enabled = 1,
+   .enabled = 0,
.loglevel = LOGL_DEBUG,
},
[DTPDU] = {
.name = "TPDU",
.description = "TPDU FSM",
-   .enabled = 1,
+   .enabled = 0,
.loglevel = LOGL_DEBUG,
},
[DPPS] = {
.name = "PPS",
.description = "PPS (Protocol and Parameter Selection) FSM",
-   .enabled = 1,
+   .enabled = 0,
.loglevel = LOGL_DEBUG,
},
[DCARD] = {
.name = "CARD",
.description = "Card FSM",
-   .enabled = 1,
+   .enabled = 0,
.loglevel = LOGL_DEBUG,
},
 };
@@ -150,16 +150,18 @@
struct log_target *stderr_target;

/* msgb */
+#if 0
g_msgb_ctx = talloc_pool(g_tall_ctx, 20480);
talloc_set_memlimit(g_msgb_ctx, 20480);
msgb_talloc_ctx_init(g_msgb_ctx, 0);
-
+#endif
/* logging */
log_init(&log_info, g_tall_ctx);
+#if 0
stderr_target = log_target_create_stderr_raw();
log_add_target(stderr_target);
log_set_all_filter(stderr_target, 1);
-
+#endif
/* timer */
SysTick_Config(SystemCoreClock / 1000);
 }
diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index 059c99d..0f2409a 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -463,6 +463,9 @@
g_tall_ctx = talloc_named_const(NULL, 0, "global");
printf("g_tall_ctx=%p\r\n", g_tall_ctx);

+   //FIXME osmo_emb has a pool?
+   msgb_talloc_ctx_init(g_tall_ctx, 0);
+
libosmo_emb_init();

LOGP(DUSB, LOGL_ERROR, "foobar usb\n");

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16270
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Iaf5123ab0340efec7b8e11e689f529f2e95e31ca
Gerrit-Change-Number: 16270
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: add a "no rx or tx" state

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16279 )


Change subject: add a "no rx or tx" state
..

add a "no rx or tx" state

Change-Id: I27def4feff5a01b751fd48c5aa844ffdbb087f63
---
M ccid_common/cuart.h
M ccid_common/iso7816_fsm.c
M sysmoOCTSIM/cuart_driver_asf4_usart_async.c
3 files changed, 4 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/79/16279/1

diff --git a/ccid_common/cuart.h b/ccid_common/cuart.h
index 6c53481..32a8daa 100644
--- a/ccid_common/cuart.h
+++ b/ccid_common/cuart.h
@@ -23,6 +23,7 @@

 enum card_uart_ctl {
CUART_CTL_RX,   /* enable/disable receiver */
+   CUART_CTL_NO_RXTX,  /* enable/disable receiver */
CUART_CTL_POWER,/* enable/disable ICC power */
CUART_CTL_CLOCK,/* enable/disable ICC clock */
CUART_CTL_CLOCK_FREQ, /* set ICC clock frequency (hz)*/
diff --git a/ccid_common/iso7816_fsm.c b/ccid_common/iso7816_fsm.c
index 031f6b0..623193f 100644
--- a/ccid_common/iso7816_fsm.c
+++ b/ccid_common/iso7816_fsm.c
@@ -305,7 +305,7 @@
 {
struct iso7816_3_priv *ip = get_iso7816_3_priv(fi);
OSMO_ASSERT(fi->fsm == &iso7816_3_fsm);
-   card_uart_ctrl(ip->uart, CUART_CTL_RX, false);
+   card_uart_ctrl(ip->uart, CUART_CTL_NO_RXTX, true);
/* reset the TPDU state machine */
osmo_fsm_inst_dispatch(ip->tpdu_fi, ISO7816_E_TPDU_CLEAR_REQ, NULL);
 }
diff --git a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c 
b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
index a8f8044..21ab5a4 100644
--- a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
+++ b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
@@ -348,6 +348,8 @@
Sercom *sercom = cuart->u.asf4.usa_pd->device.hw;

switch (ctl) {
+   case CUART_CTL_NO_RXTX:
+   break;
case CUART_CTL_RX:
if (arg){
sercom->USART.CTRLB.bit.RXEN = 1;

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16279
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I27def4feff5a01b751fd48c5aa844ffdbb087f63
Gerrit-Change-Number: 16279
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: add a note for D=64 pecularities

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16285 )


Change subject: add a note for D=64 pecularities
..

add a note for D=64 pecularities

Change-Id: Icf2845e0f07f2d23f5090d35b6d8d145ad65a2f8
---
M ccid_common/ccid_slot_fsm.c
1 file changed, 8 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/85/16285/1

diff --git a/ccid_common/ccid_slot_fsm.c b/ccid_common/ccid_slot_fsm.c
index 9be31d6..d7740fe 100644
--- a/ccid_common/ccid_slot_fsm.c
+++ b/ccid_common/ccid_slot_fsm.c
@@ -287,6 +287,14 @@

ss->seq = seq;

+   /* FIXME:
+   When  using  D=64,  the  interface  device  shall  ensure  a  delay
+ of  at  least  16  etu  between  the  leading  edge  of  the last
+  received character and the leading edge of the character transmitted
+   for initiating a command.
+   -> we can't really do 4 stop bits?!
+   */
+
/* Hardware does not support SPU, so no PPS2, and PPS3 is reserved 
anyway */
tpdu = msgb_alloc(6, "PPSRQ");
OSMO_ASSERT(tpdu);

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16285
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Icf2845e0f07f2d23f5090d35b6d8d145ad65a2f8
Gerrit-Change-Number: 16285
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: talloc asserts

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16269 )


Change subject: talloc asserts
..

talloc asserts

Change-Id: I00df6e41f38eba6b6f06a0dab52035f446718a99
---
M sysmoOCTSIM/talloc.c
1 file changed, 10 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/69/16269/1

diff --git a/sysmoOCTSIM/talloc.c b/sysmoOCTSIM/talloc.c
index c5c9062..918cf42 100644
--- a/sysmoOCTSIM/talloc.c
+++ b/sysmoOCTSIM/talloc.c
@@ -30,6 +30,10 @@
   inspired by http://swapped.cc/halloc/
 */

+#include 
+#include 
+#include 
+
 #include "replace.h"
 #include "talloc.h"

@@ -727,6 +731,9 @@
size_t total_len = TC_HDR_SIZE + size + prefix_len;
struct talloc_chunk *parent = NULL;

+   // do not allocate while handling interrupts!
+   OSMO_ASSERT( !(SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) )
+
if (unlikely(context == NULL)) {
context = null_context;
}
@@ -1740,6 +1747,9 @@
 {
struct talloc_chunk *tc;

+   // do not deallocate while handling interrupts!
+   OSMO_ASSERT( !(SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) )
+
if (unlikely(ptr == NULL)) {
return -1;
}

--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16269
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I00df6e41f38eba6b6f06a0dab52035f446718a99
Gerrit-Change-Number: 16269
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-MessageType: newchange


Change in osmo-ccid-firmware[master]: ccid setparameters/PPS support

2019-11-27 Thread Hoernchen
Hoernchen has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16274 )


Change subject: ccid setparameters/PPS support
..

ccid setparameters/PPS support

Change-Id: I280969ec9fe681dedae14ae8e6806f69eed3ff5a
---
M ccid_common/ccid_device.c
M ccid_common/ccid_device.h
M ccid_common/ccid_slot_fsm.c
M ccid_common/iso7816_fsm.c
M ccid_common/iso7816_fsm.h
5 files changed, 322 insertions(+), 21 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/74/16274/1

diff --git a/ccid_common/ccid_device.c b/ccid_common/ccid_device.c
index 8183b16..c67c52e 100644
--- a/ccid_common/ccid_device.c
+++ b/ccid_common/ccid_device.c
@@ -23,9 +23,11 @@
 /* decode on-the-wire T0 parameters into their parsed form */
 static int decode_ccid_pars_t0(struct ccid_pars_decoded *out, const struct 
ccid_proto_data_t0 *in)
 {
-   /* input validation: only 0x00 and 0x02 permitted for bmTCCKST0 */
-   if (in->bmTCCKST0 & 0xFD)
-   return -11;
+   /* input validation: only 0x00 and 0x02 permitted for bmTCCKST0
+* if (in->bmTCCKST0 & 0xFD)
+*  return -11;
+* 7816-3 6.1.7 says: "Note: the CCID ignores this bit", placeholder 
for GETparameters */
+
/* input validation: only 0x00 to 0x03 permitted for bClockSTop */
if (in->bClockStop & 0xFC)
return -14;
@@ -254,7 +256,7 @@
}
return msg;
 }
-static struct msgb *ccid_gen_parameters_t0(struct ccid_slot *cs, uint8_t seq, 
uint8_t cmd_sts,
+struct msgb *ccid_gen_parameters_t0(struct ccid_slot *cs, uint8_t seq, uint8_t 
cmd_sts,
   enum ccid_error_code err)
 {
return ccid_gen_parameters_t0_nr(cs->slot_nr, get_icc_status(cs), seq, 
cmd_sts, err, &cs->pars);
@@ -276,7 +278,7 @@
}
return msg;
 }
-static struct msgb *ccid_gen_parameters_t1(struct ccid_slot *cs, uint8_t seq, 
uint8_t cmd_sts,
+struct msgb *ccid_gen_parameters_t1(struct ccid_slot *cs, uint8_t seq, uint8_t 
cmd_sts,
   enum ccid_error_code err)
 {
return ccid_gen_parameters_t1_nr(cs->slot_nr, get_icc_status(cs), seq, 
cmd_sts, err, &cs->pars);
@@ -465,7 +467,7 @@

/* copy default parameters from somewhere */
/* FIXME: T=1 */
-   cs->ci->slot_ops->set_params(cs, CCID_PROTOCOL_NUM_T0, 
cs->default_pars);
+   cs->ci->slot_ops->set_params(cs, seq, CCID_PROTOCOL_NUM_T0, 
cs->default_pars);
cs->pars = *cs->default_pars;

resp = ccid_gen_parameters_t0(cs, seq, CCID_CMD_STATUS_OK, 0);
@@ -502,14 +504,16 @@
goto out;
}

+   cs->proposed_pars = pars_dec;
+
/* validate parameters; abort if they are not supported */
-   rc = cs->ci->slot_ops->set_params(cs, spar->bProtocolNum, &pars_dec);
+   rc = cs->ci->slot_ops->set_params(cs, seq, spar->bProtocolNum, 
&pars_dec);
if (rc < 0) {
resp = ccid_gen_parameters_t0(cs, seq, CCID_CMD_STATUS_FAILED, 
-rc);
-   } else {
-   cs->pars = pars_dec;
-   resp = ccid_gen_parameters_t0(cs, seq, CCID_CMD_STATUS_OK, 0);
+   goto out;
}
+   /* busy, tdpu like callback */
+   return 1;
 out:
return ccid_slot_send_unbusy(cs, resp);
 }
diff --git a/ccid_common/ccid_device.h b/ccid_common/ccid_device.h
index ae3ab5b..8390783 100644
--- a/ccid_common/ccid_device.h
+++ b/ccid_common/ccid_device.h
@@ -53,6 +53,8 @@
bool cmd_busy;
/* decided CCID parameters */
struct ccid_pars_decoded pars;
+   /* proposed CCID parameters */
+   struct ccid_pars_decoded proposed_pars;
/* default parameters; applied on ResetParameters */
const struct ccid_pars_decoded *default_pars;
 };
@@ -80,7 +82,7 @@
const struct ccid_pc_to_rdr_xfr_block *xfb);
void (*set_power)(struct ccid_slot *cs, bool enable);
void (*set_clock)(struct ccid_slot *cs, enum ccid_clock_command cmd);
-   int (*set_params)(struct ccid_slot *cs, enum ccid_protocol_num proto,
+   int (*set_params)(struct ccid_slot *cs, uint8_t seq, enum 
ccid_protocol_num proto,
  const struct ccid_pars_decoded *pars_dec);
int (*set_rate_and_clock)(struct ccid_slot *cs, uint32_t freq_hz, 
uint32_t rate_bps);
 };
@@ -118,6 +120,10 @@
const uint32_t *data_rates, const uint32_t *clock_freqs,
const char *name, void *priv);
 int ccid_handle_out(struct ccid_instance *ci, struct msgb *msg);
+struct msgb *ccid_gen_parameters_t0(struct ccid_slot *cs, uint8_t seq, uint8_t 
cmd_sts,
+  enum ccid_error_code err);
+struct msgb *ccid_gen_parameters_t1(struct ccid_slot *cs, uint8_t seq, uint8_t 
cmd_sts,
+  enum ccid_error_code err);


Change in osmo-bts[master]: l1sap.c: ensure ms power control loop is running

2019-11-27 Thread pespin
pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/16233 )

Change subject: l1sap.c: ensure ms power control loop is running
..


Patch Set 3:

(1 comment)

https://gerrit.osmocom.org/c/osmo-bts/+/16233/3//COMMIT_MSG
Commit Message:

https://gerrit.osmocom.org/c/osmo-bts/+/16233/3//COMMIT_MSG@15
PS3, Line 15: last known ms power setting.
It's not the last known ms power setting, but the requested one by the BTS/BSC 
:)



--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/16233
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I4fb85754b1a69376b02da7f4b175c6e8ec9cc35c
Gerrit-Change-Number: 16233
Gerrit-PatchSet: 3
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-CC: pespin 
Gerrit-Comment-Date: Wed, 27 Nov 2019 16:33:01 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: WIP: attempt to use iso7816_fsm + Cuart from firmware

2019-11-27 Thread Hoernchen
Hoernchen has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/15724 )

Change subject: WIP: attempt to use iso7816_fsm + Cuart from firmware
..


Patch Set 6: Code-Review-2


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/15724
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I1d7c9371406ecfadc565fdf047dd935ec48f
Gerrit-Change-Number: 15724
Gerrit-PatchSet: 6
Gerrit-Owner: laforge 
Gerrit-Assignee: Hoernchen 
Gerrit-Reviewer: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 15:59:01 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: WIP: Add card_uart driver for ASF4 USART

2019-11-27 Thread Hoernchen
Hoernchen has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/15723 )

Change subject: WIP: Add card_uart driver for ASF4 USART
..


Patch Set 6: Code-Review-2


--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/15723
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I9a141e9d2125fbfc992ad51aa4b11a39ee186607
Gerrit-Change-Number: 15723
Gerrit-PatchSet: 6
Gerrit-Owner: laforge 
Gerrit-Assignee: Hoernchen 
Gerrit-Reviewer: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 27 Nov 2019 15:58:53 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-ccid-firmware[master]: enable the final slot

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16254 )

Change subject: enable the final slot
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16254
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I1c18459d7e43e6fbd1022fabb52138904f2bf480
Gerrit-Change-Number: 16254
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: first attempt at timeout handling

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16253 )

Change subject: first attempt at timeout handling
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16253
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I96315fed5696ccd75318ebd88cb7725ed7568c07
Gerrit-Change-Number: 16253
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: cuart cleanup

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16251 )

Change subject: cuart cleanup
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16251
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ia5b66a86f0f53e5123139c3c5047f70582d1bf6e
Gerrit-Change-Number: 16251
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: prettier slot bitmask code

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16255 )

Change subject: prettier slot bitmask code
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16255
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Iaeb97a12f04c6f07ab59b290bad5519b45300916
Gerrit-Change-Number: 16255
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: remove old uart commands

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16252 )

Change subject: remove old uart commands
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16252
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I91fff5d8c296661bcef8576244079f3a5fc8800b
Gerrit-Change-Number: 16252
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: the magic sauce that makes it work

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16250 )

Change subject: the magic sauce that makes it work
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16250
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I25ba236b5a3a2c876ace4ca4398061889b4a9bff
Gerrit-Change-Number: 16250
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: add a note for D=64 pecularities

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16247 )

Change subject: add a note for D=64 pecularities
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16247
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I3da1f0172737c8208325a6ec5aff72fa68355963
Gerrit-Change-Number: 16247
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: boost the uart interrupt priority

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16249 )

Change subject: boost the uart interrupt priority
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16249
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ic1873922c042c45335320bdb669cf2a9346eaa81
Gerrit-Change-Number: 16249
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: assert on free in interrupt, too

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16241 )

Change subject: assert on free in interrupt, too
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16241
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I825496c81c2259f4af7f80089a0b047c5600a211
Gerrit-Change-Number: 16241
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: additional descriptor fixes

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16239 )

Change subject: additional descriptor fixes
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16239
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I5ebe907b3c35107e5a50cbc65835aca75e617c41
Gerrit-Change-Number: 16239
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: pps warning

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16248 )

Change subject: pps warning
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16248
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ie0cbca9c901643268adddc69c08be494432a3235
Gerrit-Change-Number: 16248
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: attempt at handling card insertion/removal

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16238 )

Change subject: attempt at handling card insertion/removal
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16238
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ib1a9a9c5cfb8c22cc3b885bc30a349e0f0145630
Gerrit-Change-Number: 16238
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: make it work, async uart (mode 0x1/0x7 does not matter), requires delay

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16235 )

Change subject: make it work, async uart (mode 0x1/0x7 does not matter), 
requires delay
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16235
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ia9d3b099181c24feabdb6a5fddb8db6c44efb72d
Gerrit-Change-Number: 16235
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: better error handling

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16244 )

Change subject: better error handling
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16244
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I9983c2f58c7f420a0132d186f344ace1de616ba1
Gerrit-Change-Number: 16244
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: fix power descriptor value

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16245 )

Change subject: fix power descriptor value
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16245
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Id7231c2315b141d2f6e88a0ddd4eca3b9384ecc8
Gerrit-Change-Number: 16245
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: fsm completion event handling from main loop

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16246 )

Change subject: fsm completion event handling from main loop
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16246
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: If71a37dcaa5162c18d83e4b2a0cdae69574b92d9
Gerrit-Change-Number: 16246
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: setparameters/PPS works

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16237 )

Change subject: setparameters/PPS works
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16237
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I2e226b0033f8a147fad60a33a63cc45ee9adc756
Gerrit-Change-Number: 16237
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: disable talloc_memlimit() and use existing msgb_context (pool)

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16242 )

Change subject: disable talloc_memlimit() and use existing msgb_context (pool)
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16242
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I7d3a00ea4581b4f01e72294ac4e810e54c410e24
Gerrit-Change-Number: 16242
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: dbg

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16243 )

Change subject: dbg
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16243
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I4340cb53f0f903842eb1c4d60a36d44ac9e5cbde
Gerrit-Change-Number: 16243
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: proper sercom config for the other 6 slots

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16240 )

Change subject: proper sercom config for the other 6 slots
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16240
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I266014e4d3ff09be9c5cdd5a686d6d2f5668145a
Gerrit-Change-Number: 16240
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-MessageType: abandon


Change in osmo-ccid-firmware[master]: prevent uart interrupts before having proper structs

2019-11-27 Thread Hoernchen
Hoernchen has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16236 )

Change subject: prevent uart interrupts before having proper structs
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16236
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I177b182e5c693da34183e9066351e6930c61e4a6
Gerrit-Change-Number: 16236
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: abandon


Change in osmo-hlr[master]: add mDNS lookup method to libosmo-mslookup

2019-11-27 Thread neels
Hello osmith, Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmo-hlr/+/16256

to look at the new patch set (#5).

Change subject: add mDNS lookup method to libosmo-mslookup
..

add mDNS lookup method to libosmo-mslookup

Add the first actually useful lookup method to the mslookup library: multicast
DNS.

The server side is added in a subsequent commit, when the mslookup server is
implemented for the osmo-hlr program.

Use custom DNS encoding instead of libc-ares (which we use in OsmoSGSN
already), because libc-ares is only a DNS client implementation and we will
need both client and server.

Related: OS#4237
Patch-by: osmith, nhofmeyr
Change-Id: I03a0ffa1d4dc1b24ac78a5ad0975bca90a49c728
---
M .gitignore
M configure.ac
M include/Makefile.am
M include/osmocom/Makefile.am
A include/osmocom/mslookup/Makefile.am
A include/osmocom/mslookup/mdns.h
A include/osmocom/mslookup/mdns_msg.h
A include/osmocom/mslookup/mdns_rfc.h
A include/osmocom/mslookup/mdns_sock.h
A include/osmocom/mslookup/mslookup_client_mdns.h
M src/mslookup/Makefile.am
A src/mslookup/mdns.c
A src/mslookup/mdns_msg.c
A src/mslookup/mdns_rfc.c
A src/mslookup/mdns_sock.c
A src/mslookup/mslookup_client_mdns.c
M tests/mslookup/Makefile.am
A tests/mslookup/mdns_test.c
A tests/mslookup/mdns_test.err
A tests/mslookup/mslookup_client_mdns_test.c
A tests/mslookup/mslookup_client_mdns_test.err
M tests/testsuite.at
22 files changed, 2,779 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/56/16256/5
--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16256
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I03a0ffa1d4dc1b24ac78a5ad0975bca90a49c728
Gerrit-Change-Number: 16256
Gerrit-PatchSet: 5
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith 
Gerrit-MessageType: newpatchset


Change in osmo-hlr[master]: vty: show subscriber: show lu d, h, m, s ago, not just seconds

2019-11-27 Thread neels
neels has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-hlr/+/16262 )


Change subject: vty: show subscriber: show lu d,h,m,s ago, not just seconds
..

vty: show subscriber: show lu d,h,m,s ago, not just seconds

Change-Id: I0fe34e0f065160ef959b2b7b4dd040f3f2985f43
---
M src/hlr_vty_subscr.c
1 file changed, 14 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/62/16262/1

diff --git a/src/hlr_vty_subscr.c b/src/hlr_vty_subscr.c
index 0512ff6..dfbf72f 100644
--- a/src/hlr_vty_subscr.c
+++ b/src/hlr_vty_subscr.c
@@ -57,8 +57,20 @@
vty_out(vty, "last LU seen on %s: %s", domain_label, 
get_datestr(&last_lu_seen, datebuf, sizeof(datebuf)));
if (!timestamp_age(&last_lu_seen, &age))
vty_out(vty, " (invalid timestamp)%s", VTY_NEWLINE);
-   else
-   vty_out(vty, " (%us ago)%s", age, VTY_NEWLINE);
+   else {
+   vty_out(vty, " (");
+#define UNIT_AGO(UNITNAME, UNITVAL) \
+   if (age >= (UNITVAL)) { \
+   vty_out(vty, "%u%s", age / (UNITVAL), UNITNAME); \
+   age = age % (UNITVAL); \
+   }
+   UNIT_AGO("d", 60*60*24);
+   UNIT_AGO("h", 60*60);
+   UNIT_AGO("m", 60);
+   UNIT_AGO("s", 1);
+   vty_out(vty, " ago)%s", VTY_NEWLINE);
+#undef UNIT_AGO
+   }
 }

 static void subscr_dump_full_vty(struct vty *vty, struct hlr_subscriber 
*subscr)

--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16262
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I0fe34e0f065160ef959b2b7b4dd040f3f2985f43
Gerrit-Change-Number: 16262
Gerrit-PatchSet: 1
Gerrit-Owner: neels 
Gerrit-MessageType: newchange


Change in osmo-hlr[master]: vty: show subscriber: change format of 'last LU seen'

2019-11-27 Thread neels
neels has uploaded a new patch set (#5) to the change originally created by 
laforge. ( https://gerrit.osmocom.org/c/osmo-hlr/+/15359 )

Change subject: vty: show subscriber: change format of 'last LU seen'
..

vty: show subscriber: change format of 'last LU seen'

So far, the time string format comes from ctime_r, and we manually add "UTC" to 
it.

The ctime_r format is wildly chaotic IMHO, mixing weekday, day-of-month and
hour and year in very unsorted ways.

Adding "UTC" to it is non-standard.

Instead use an ISO-8601 standardized time string via strftime().

Change-Id: I6731968f05050399f4dd43b241290186e0c59e1a
---
M src/hlr_vty_subscr.c
1 file changed, 10 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/59/15359/5
--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/15359
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I6731968f05050399f4dd43b241290186e0c59e1a
Gerrit-Change-Number: 15359
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Reviewer: pespin 
Gerrit-CC: neels 
Gerrit-MessageType: newpatchset


Change in osmo-hlr[master]: change format of 'last LU seen'

2019-11-27 Thread neels
neels has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-hlr/+/15359 )

Change subject: change format of 'last LU seen'
..


Patch Set 4:

I took the liberty to rebase this onto the dgsm branch to avoid a merge 
conflict;
fixed the condition; removed the static char[].


--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/15359
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I6731968f05050399f4dd43b241290186e0c59e1a
Gerrit-Change-Number: 15359
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Reviewer: pespin 
Gerrit-CC: neels 
Gerrit-Comment-Date: Wed, 27 Nov 2019 15:41:20 +
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in osmo-hlr[master]: change format of 'last LU seen'

2019-11-27 Thread neels
neels has uploaded a new patch set (#4) to the change originally created by 
laforge. ( https://gerrit.osmocom.org/c/osmo-hlr/+/15359 )

Change subject: change format of 'last LU seen'
..

change format of 'last LU seen'

So far, the time string format comes from ctime_r, and we manually add "UTC" to 
it.

The ctime_r format is wildly chaotic IMHO, mixing weekday, day-of-month and
hour and year in very unsorted ways.

Adding "UTC" to it is non-standard.

Instead use an ISO-8601 standardized time string via strftime().

Change-Id: I6731968f05050399f4dd43b241290186e0c59e1a
---
M src/hlr_vty_subscr.c
1 file changed, 10 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/59/15359/4
--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/15359
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I6731968f05050399f4dd43b241290186e0c59e1a
Gerrit-Change-Number: 15359
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Reviewer: pespin 
Gerrit-MessageType: newpatchset


Change in osmo-hlr[master]: add libosmo-mslookup abstract client

2019-11-27 Thread neels
Hello fixeria, pespin, laforge, osmith, Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmo-hlr/+/16202

to look at the new patch set (#15).

Change subject: add libosmo-mslookup abstract client
..

add libosmo-mslookup abstract client

mslookup is a key concept in Distributed GSM, which allows querying the current
location of a subscriber in a number of cooperating but independent core
network sites, by arbitrary service names and by MSISDN/IMSI.

Add the abstract mslookup client library. An actual lookup method (besides
mslookup_client_fake.c) is added in a subsequent patch.

For a detailed overview of this and upcoming patches, please see the elaborate
comment at the top of mslookup.c.

Add as separate library, libosmo-mslookup, to allow adding D-GSM capability to
arbitrary client programs.

osmo-hlr will be the mslookup server, added in a subsequent patch.

osmo-hlr itself will also use this library and act as an mslookup client, when
requesting the home HLR for locally unknown IMSIs.

Related: OS#4237
Patch-by: osmith, nhofmeyr
Change-Id: I83487ab8aad1611eb02e997dafbcb8344da13df1
---
M .gitignore
M configure.ac
M debian/control
A debian/libosmo-mslookup-dev.install
A debian/libosmo-mslookup0.install
M include/Makefile.am
M include/osmocom/hlr/logging.h
A include/osmocom/mslookup/mslookup.h
A include/osmocom/mslookup/mslookup_client.h
A include/osmocom/mslookup/mslookup_client_fake.h
A libosmo-mslookup.pc.in
M src/Makefile.am
A src/mslookup/Makefile.am
A src/mslookup/mslookup.c
A src/mslookup/mslookup_client.c
A src/mslookup/mslookup_client_fake.c
M tests/Makefile.am
A tests/mslookup/Makefile.am
A tests/mslookup/mslookup_client_test.c
A tests/mslookup/mslookup_client_test.err
A tests/mslookup/mslookup_test.c
A tests/mslookup/mslookup_test.err
M tests/testsuite.at
23 files changed, 1,620 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/02/16202/15
--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16202
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I83487ab8aad1611eb02e997dafbcb8344da13df1
Gerrit-Change-Number: 16202
Gerrit-PatchSet: 15
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: neels 
Gerrit-Reviewer: osmith 
Gerrit-Reviewer: pespin 
Gerrit-MessageType: newpatchset


Change in osmo-hlr[master]: add mDNS lookup method to libosmo-mslookup

2019-11-27 Thread neels
Hello osmith, Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmo-hlr/+/16256

to look at the new patch set (#4).

Change subject: add mDNS lookup method to libosmo-mslookup
..

add mDNS lookup method to libosmo-mslookup

Add the first actually useful lookup method to the mslookup library: multicast
DNS.

The server side is added in a subsequent commit, when the mslookup server is
implemented for the osmo-hlr program.

Use custom DNS encoding instead of libc-ares (which we use in OsmoSGSN
already), because libc-ares is only a DNS client implementation and we will
need both client and server.

Related: OS#4237
Patch-by: osmith, nhofmeyr
Change-Id: I03a0ffa1d4dc1b24ac78a5ad0975bca90a49c728
---
M .gitignore
M configure.ac
M include/Makefile.am
A include/osmocom/mslookup/Makefile.am
A include/osmocom/mslookup/mdns.h
A include/osmocom/mslookup/mdns_msg.h
A include/osmocom/mslookup/mdns_rfc.h
A include/osmocom/mslookup/mdns_sock.h
A include/osmocom/mslookup/mslookup_client_mdns.h
M src/mslookup/Makefile.am
A src/mslookup/mdns.c
A src/mslookup/mdns_msg.c
A src/mslookup/mdns_rfc.c
A src/mslookup/mdns_sock.c
A src/mslookup/mslookup_client_mdns.c
M tests/mslookup/Makefile.am
A tests/mslookup/mdns_test.c
A tests/mslookup/mdns_test.err
A tests/mslookup/mslookup_client_mdns_test.c
A tests/mslookup/mslookup_client_mdns_test.err
M tests/testsuite.at
21 files changed, 2,778 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/56/16256/4
--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16256
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I03a0ffa1d4dc1b24ac78a5ad0975bca90a49c728
Gerrit-Change-Number: 16256
Gerrit-PatchSet: 4
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith 
Gerrit-MessageType: newpatchset


Change in osmo-hlr[master]: db v4: add column last_lu_seen_ps

2019-11-27 Thread osmith
osmith has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-hlr/+/16201 )

Change subject: db v4: add column last_lu_seen_ps
..


Patch Set 6: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16201
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: Id7fc50567211a0870ac0524f6dee94d4513781ba
Gerrit-Change-Number: 16201
Gerrit-PatchSet: 6
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: neels 
Gerrit-Reviewer: osmith 
Gerrit-Reviewer: pespin 
Gerrit-Comment-Date: Wed, 27 Nov 2019 15:17:46 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-bts[master]: l1sap.c: ensure ms power control loop is running

2019-11-27 Thread dexter
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmo-bts/+/16233

to look at the new patch set (#3).

Change subject: l1sap.c: ensure ms power control loop is running
..

l1sap.c: ensure ms power control loop is running

When a bad SACCH frame is received the processing of the frame is ended
early and lchan_ms_pwr_ctrl() is not called. This means that the power
control loop does not get informed about a situation where the signal
level is very weak and increasing the ms power would make sense. In
order to ensure that the power control keeps working on lost SACCH
frames, lets call lchan_ms_pwr_ctrl() with the current RSSI and the
last known ms power setting.

Related: OS#4281
Change-Id: I4fb85754b1a69376b02da7f4b175c6e8ec9cc35c
---
M src/common/l1sap.c
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/33/16233/3
--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/16233
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I4fb85754b1a69376b02da7f4b175c6e8ec9cc35c
Gerrit-Change-Number: 16233
Gerrit-PatchSet: 3
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-CC: pespin 
Gerrit-MessageType: newpatchset


Change in osmo-hlr[master]: db v4: add column last_lu_seen_ps

2019-11-27 Thread pespin
pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-hlr/+/16201 )

Change subject: db v4: add column last_lu_seen_ps
..


Patch Set 6: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16201
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: Id7fc50567211a0870ac0524f6dee94d4513781ba
Gerrit-Change-Number: 16201
Gerrit-PatchSet: 6
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: neels 
Gerrit-Reviewer: osmith 
Gerrit-Reviewer: pespin 
Gerrit-Comment-Date: Wed, 27 Nov 2019 15:06:03 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-hlr[master]: add libosmo-mslookup abstract client

2019-11-27 Thread neels
neels has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-hlr/+/16202 )

Change subject: add libosmo-mslookup abstract client
..


Patch Set 14:

(6 comments)

https://gerrit.osmocom.org/c/osmo-hlr/+/16202/14/src/mslookup/mslookup.c
File src/mslookup/mslookup.c:

https://gerrit.osmocom.org/c/osmo-hlr/+/16202/14/src/mslookup/mslookup.c@52
PS14, Line 52:  *   src/mslookup/mslookup_client_mdns.c   lookup method 
implementing multicast DNS, client side.
> This line should go in next patches but fine.
(this was explicitly meant as an overview across all upcoming patches)


https://gerrit.osmocom.org/c/osmo-hlr/+/16202/14/src/mslookup/mslookup.c@61
PS14, Line 61:  *   contrib/dgsm/esme_dgsm.py Example 
implementation for an mslookup enabled SMS handler.
> utils/?
IMHO it still belongs in contrib


https://gerrit.osmocom.org/c/osmo-hlr/+/16202/14/src/mslookup/mslookup.c@80
PS14, Line 80:  *  src/proxy.c   Keep track of proxied IMSIs and cache 
important subscriber data.
> is code in this file going to be used outside of dgsm scope? if not, sounds 
> like it should be rename […]
D-GSM is the concept for finding out where to proxy to, the GSUP proxy itself 
is a building block not necessarily limited to D-GSM


https://gerrit.osmocom.org/c/osmo-hlr/+/16202/14/src/mslookup/mslookup.c@91
PS14, Line 91: #define CMP(a,b) (a < b? -1 : (a > b? 1 : 0))
> Don't we have an OSMO_CMP somewhere for that? BTW, missing () around a and b. 
> Missing space after b.
ah indeed


https://gerrit.osmocom.org/c/osmo-hlr/+/16202/14/src/mslookup/mslookup.c@214
PS14, Line 214: if (result->host_v4.ip[0]) {
> != '\0'. […]
this is literally the least interesting aspect of these patches that we could 
possibly discuss :P


https://gerrit.osmocom.org/c/osmo-hlr/+/16202/14/src/mslookup/mslookup_client.c
File src/mslookup/mslookup_client.c:

https://gerrit.osmocom.org/c/osmo-hlr/+/16202/14/src/mslookup/mslookup_client.c@72
PS14, Line 72:  if (!client)
> do we really expect someone to call this function with a null pointer? I 
> wouldn't expect it. […]
no, I want to return false if the client is not allocated, not abort the 
program.

 osmo_mslookup_client_active(g_hlr->mslookup.client.running);



--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16202
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I83487ab8aad1611eb02e997dafbcb8344da13df1
Gerrit-Change-Number: 16202
Gerrit-PatchSet: 14
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: neels 
Gerrit-Reviewer: osmith 
Gerrit-CC: pespin 
Gerrit-Comment-Date: Wed, 27 Nov 2019 15:00:01 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin 
Gerrit-MessageType: comment


Change in osmo-hlr[master]: db v4: add column last_lu_seen_ps

2019-11-27 Thread neels
neels has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-hlr/+/16201 )

Change subject: db v4: add column last_lu_seen_ps
..


Patch Set 6:

> Patch Set 5:
>
> Why does it matter whether attachment is CS or PS? please explain better the 
> rationale behind this change from user case / scenario point of view.

MSC and SGSN are two distinct clients connecting to the HLR and previously both 
overwrite the same last_lu_seen item. It is theoretically possible that the 
SGSN talks to a different  HLR than the MSC, or that the SGSN does a LU later 
than the MSC, and, as the commit log states, for D-GSM I need to find out where 
the *CS* has been attached. If the SGSN modifies the same data, it may corrupt 
the decision of where a subscriber is currently attached for voice calls and 
SMS.


--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16201
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: Id7fc50567211a0870ac0524f6dee94d4513781ba
Gerrit-Change-Number: 16201
Gerrit-PatchSet: 6
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: neels 
Gerrit-Reviewer: osmith 
Gerrit-CC: pespin 
Gerrit-Comment-Date: Wed, 27 Nov 2019 14:44:14 +
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in libosmocore[master]: Introduce fields related to DTAP DLCI

2019-11-27 Thread pespin
Hello fixeria, Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/16259

to look at the new patch set (#2).

Change subject: Introduce fields related to DTAP DLCI
..

Introduce fields related to DTAP DLCI

Change-Id: Iec448af02d28e6c5c573e68a0b4a86067ec7e561
---
M include/osmocom/gsm/protocol/gsm_08_08.h
M src/gsm/gsm0808.c
M src/gsm/libosmogsm.map
3 files changed, 36 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/59/16259/2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/16259
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Iec448af02d28e6c5c573e68a0b4a86067ec7e561
Gerrit-Change-Number: 16259
Gerrit-PatchSet: 2
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-MessageType: newpatchset


  1   2   >