Change in osmo-ttcn3-hacks[master]: MSC/BSC_ConnectionHandler: only keep SMSC address in SmsParametersRp

2019-12-15 Thread fixeria
fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16597 )


Change subject: MSC/BSC_ConnectionHandler: only keep SMSC address in 
SmsParametersRp
..

MSC/BSC_ConnectionHandler: only keep SMSC address in SmsParametersRp

When sending MO or MT SMS, we never include both SM-RP-DA/OA IEs
at the same time. In case of MO SMS, SM-RP-OA is omitted, and in
case of MT SMS - SM-RP-DA is omitted.

Change-Id: Ia60bdd2498034b6b849f874cf1eee272abef2b47
---
M msc/BSC_ConnectionHandler.ttcn
M msc/MSC_Tests.ttcn
2 files changed, 16 insertions(+), 6 deletions(-)



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

diff --git a/msc/BSC_ConnectionHandler.ttcn b/msc/BSC_ConnectionHandler.ttcn
index 0846c04..3dde9b4 100644
--- a/msc/BSC_ConnectionHandler.ttcn
+++ b/msc/BSC_ConnectionHandler.ttcn
@@ -1618,8 +1618,7 @@
 }
 type record SmsParametersRp {
OCT1msg_ref,
-   RP_NumberingPlan_and_NumberDigits orig optional,
-   RP_NumberingPlan_and_NumberDigits dest optional
+   RP_NumberingPlan_and_NumberDigits smsc_addr optional
 }
 type record SmsParameters {
SmsParametersTp tp,
@@ -1639,6 +1638,16 @@
}
 }

+template RP_NumberingPlan_and_NumberDigits t_RP_Addr(template hexstring addr,
+template BIT4 npi := 
'0001'B,
+template BIT3 ton := 
'001'B,
+template BIT1 ext := '1'B) 
:= {
+   rP_NumberingPlanIdentification := npi,
+   rP_TypeOfNumber := ton,
+   rP_Ext := ext,
+   rP_NumberDigits := addr
+}
+
 template (value) SmsParameters t_SmsPars(hexstring tp_daddr := '12345'H) := {
tp := {
msg_ref := '23'O,
@@ -1650,8 +1659,9 @@
},
rp := {
msg_ref := '42'O,
-   orig := omit,
-   dest := { ''B, '000'B, '0'B, '98765'H }
+   /* We don't really need to have both SM-RP-DA/OA here, because 
only one IE
+* is included in MO/MT SMS, and in the most cases it's the 
SMSC address. */
+   smsc_addr := t_RP_Addr('76722337'H)
},
tid := 0,
dlci := '03'O,
@@ -1700,7 +1710,7 @@

tp_mo := ts_SMS_SUBMIT(spars.tp.msg_ref, spars.tp.da, spars.tp.pid, 
spars.tp.dcs,
 spars.tp.udl, spars.tp.ud);
-   rp_mo := ts_RP_DATA_MO(spars.rp.msg_ref, spars.rp.orig, spars.rp.dest, 
tp_mo);
+   rp_mo := ts_RP_DATA_MO(spars.rp.msg_ref, omit, spars.rp.smsc_addr, 
tp_mo);
l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_DATA_MO(rp_mo));
BSSAP.send(ts_PDU_DTAP_MO(l3_mo, spars.dlci, true));
/* receive CP-ACK for CP-DATA above */
diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index 480ec96..87f595d 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -4621,7 +4621,7 @@

tp_mo := ts_SMS_SUBMIT(spars.tp.msg_ref, spars.tp.da, spars.tp.pid, 
spars.tp.dcs,
 spars.tp.udl, spars.tp.ud);
-   rp_mo := ts_RP_DATA_MO(spars.rp.msg_ref, spars.rp.orig, spars.rp.dest, 
tp_mo);
+   rp_mo := ts_RP_DATA_MO(spars.rp.msg_ref, omit, spars.rp.smsc_addr, 
tp_mo);
l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_DATA_MO(rp_mo));

SGsAP.send(l3_mo);

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16597
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: Ia60bdd2498034b6b849f874cf1eee272abef2b47
Gerrit-Change-Number: 16597
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria 
Gerrit-MessageType: newchange


Change in osmo-ttcn3-hacks[master]: MSC_Tests.ttcn: fix: verify the contents of SM-RP-DA/OA for MO/MT SMS

2019-12-15 Thread fixeria
Hello laforge, Jenkins Builder,

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

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

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

Change subject: MSC_Tests.ttcn: fix: verify the contents of SM-RP-DA/OA for 
MO/MT SMS
..

MSC_Tests.ttcn: fix: verify the contents of SM-RP-DA/OA for MO/MT SMS

Change-Id: Ib467eeca6439bc6cce72293fbb5bb48f6d233db9
Related: OS#4324
---
M msc/BSC_ConnectionHandler.ttcn
M msc/MSC_Tests.ttcn
2 files changed, 19 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/66/16566/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16566
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: Ib467eeca6439bc6cce72293fbb5bb48f6d233db9
Gerrit-Change-Number: 16566
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: newpatchset


Change in osmo-ttcn3-hacks[master]: library/GSUP_Types.ttcn: fix MSISDN / SMSC coding in SM-RP-OA/DA

2019-12-15 Thread fixeria
fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16565 )

Change subject: library/GSUP_Types.ttcn: fix MSISDN / SMSC coding in SM-RP-OA/DA
..


Patch Set 2:

This change is ready for review.


--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16565
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: I3f55834489f3e613f541cf1e216027e8d48ccaf0
Gerrit-Change-Number: 16565
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sun, 15 Dec 2019 13:54:14 +
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in simtrace2[master]: usb_buf: Actually limit queue to 3 elements, not 4

2019-12-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16598 )


Change subject: usb_buf: Actually limit queue to 3 elements, not 4
..

usb_buf: Actually limit queue to 3 elements, not 4

In Change-ID Ie15183f16b22193ffdaf01845db2eae4c7f43c17 we wanted
to limit the number of queue elements to 3, but actually implemented 4.

Change-Id: Ic5fb164f2dfd1c293c51bee8184fc34552267a54
---
M firmware/libcommon/source/usb_buf.c
1 file changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/98/16598/1

diff --git a/firmware/libcommon/source/usb_buf.c 
b/firmware/libcommon/source/usb_buf.c
index 7892d6e..b6ecd54 100644
--- a/firmware/libcommon/source/usb_buf.c
+++ b/firmware/libcommon/source/usb_buf.c
@@ -80,7 +80,7 @@
/* no need for irqsafe operation, as the usb_tx_queue is
 * processed only by the main loop context */

-   if (ep->queue_len > USB_MAX_QLEN) {
+   if (ep->queue_len >= USB_MAX_QLEN) {
struct msgb *evict;
/* free the first pending buffer in the queue */
TRACE_INFO("EP%02x: dropping first queue element (qlen=%u)\r\n",

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Ic5fb164f2dfd1c293c51bee8184fc34552267a54
Gerrit-Change-Number: 16598
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in simtrace2[master]: card_emu: Initialize PTSS state every time we start PTS

2019-12-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16601 )


Change subject: card_emu: Initialize PTSS state every time we start PTS
..

card_emu: Initialize PTSS state every time we start PTS

Let's shift the responsibility from the caller side to the calee side.

Change-Id: I39661ca93c87b2e2071765f69578eec5aaf90ce4
---
M firmware/libcommon/source/card_emu.c
1 file changed, 2 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/01/16601/1

diff --git a/firmware/libcommon/source/card_emu.c 
b/firmware/libcommon/source/card_emu.c
index 9ea500d..f53b3df 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -536,8 +536,6 @@
/* update waiting time (see ISO 7816-3 10.2) */
ch->waiting_time = ch->wi * 960 * ch->fi;
tc_etu_set_wtime(ch->tc_chan, ch->waiting_time);
-   /* reset PTS to initial state */
-   set_pts_state(ch, PTS_S_WAIT_REQ_PTSS);
/* go to next state */
card_set_state(ch, ISO_S_WAIT_TPDU);
return 0;
@@ -703,7 +701,6 @@
emu_update_fidi(ch);
/* Wait for the next TPDU */
card_set_state(ch, ISO_S_WAIT_TPDU);
-   set_pts_state(ch, PTS_S_WAIT_REQ_PTSS);
break;
default:
/* calculate the next state and set it */
@@ -981,6 +978,8 @@
switch (ch->state) {
case ISO_S_WAIT_TPDU:
if (byte == 0xff) {
+   /* reset PTS to initial state */
+   set_pts_state(ch, PTS_S_WAIT_REQ_PTSS);
new_state = process_byte_pts(ch, byte);
ch->stats.pps++;
goto out_silent;

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I39661ca93c87b2e2071765f69578eec5aaf90ce4
Gerrit-Change-Number: 16601
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in simtrace2[master]: cardem: RST resets all state (including release of buffers)

2019-12-15 Thread laforge
Hello Jenkins Builder,

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

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

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

Change subject: cardem: RST resets all state (including release of buffers)
..

cardem: RST resets all state (including release of buffers)

When the Modem is asserting RST, the emulated card should set all
of its state back to default/initial values and release any buffers
it may still hold in its state.

Change-Id: I66eca6afe4ff7d900c5b75df1e3ec6d52f6ef214
Related: OS#4251
---
M firmware/libcommon/source/card_emu.c
1 file changed, 23 insertions(+), 18 deletions(-)


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I66eca6afe4ff7d900c5b75df1e3ec6d52f6ef214
Gerrit-Change-Number: 16584
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in simtrace2[master]: USBD_HAL: Don't disable UDP peripheral clock on suspend

2019-12-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16599 )


Change subject: USBD_HAL: Don't disable UDP peripheral clock on suspend
..

USBD_HAL: Don't disable UDP peripheral clock on suspend

Change-Id: I2169e2140762b37661f4567bb148326afd85cddc
Closes: OS#4329
---
M firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
1 file changed, 4 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/99/16599/1

diff --git a/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c 
b/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
index 3fe3270..0eccc65 100644
--- a/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
+++ b/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
@@ -1687,7 +1687,10 @@
 /* The device enters the Suspended state */
 UDP_DisableTransceiver();
 UDP_DisableUsbClock();
-UDP_DisablePeripheralClock();
+/* Don't disable peripheral clock; this somehow breaks completion of any 
IN transfers
+ * that have already been written to the peripheral, and which we expect 
to complete
+ * after resume */
+//UDP_DisablePeripheralClock();
 }

 /**

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I2169e2140762b37661f4567bb148326afd85cddc
Gerrit-Change-Number: 16599
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in simtrace2[master]: card_emu: Remove extraneous code

2019-12-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16603 )


Change subject: card_emu: Remove extraneous code
..

card_emu: Remove extraneous code

card_set_state(ch, ISO_S_WAIT_ATR) internally calls tc_etu_enable(),
so there's no need for the caller to do the same, too.

Change-Id: I2a2b4d64c40264623313a867957ffcefe57748f9
---
M firmware/libcommon/source/card_emu.c
1 file changed, 1 insertion(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/03/16603/1

diff --git a/firmware/libcommon/source/card_emu.c 
b/firmware/libcommon/source/card_emu.c
index 66932af..0577a12 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -440,7 +440,7 @@
 * since the initial ETU is Fd=372/Dd=1 clock cycles long, we 
have to wait 2-107 ETU.
 */
tc_etu_set_wtime(ch->tc_chan, 2);
-   /* ensure the TC_ETU timer is enabled */
+   /* enable the TC/ETU counter once reset has been released */
tc_etu_enable(ch->tc_chan);
break;
case ISO_S_IN_ATR:
@@ -,8 +,6 @@
/* check end activation state (only necessary if the reader to
 * not respect the activation sequence) */
if (ch->vcc_active && ch->clocked && !ch->in_reset) {
-   /* enable the TC/ETU counter once reset has been released */
-   tc_etu_enable(ch->tc_chan);
/* prepare to send the ATR */
card_set_state(ch, ISO_S_WAIT_ATR);
}

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I2a2b4d64c40264623313a867957ffcefe57748f9
Gerrit-Change-Number: 16603
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in simtrace2[master]: usb_buf: Properly initialize buffered_endpoint->ep number

2019-12-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16600 )


Change subject: usb_buf: Properly initialize buffered_endpoint->ep number
..

usb_buf: Properly initialize buffered_endpoint->ep number

The number is used only in print statements, and it's always '0' so far.

Change-Id: Id147e24d9d50c274fec963f00494cb20e2360b33
---
M firmware/libcommon/source/usb_buf.c
1 file changed, 1 insertion(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/00/16600/1

diff --git a/firmware/libcommon/source/usb_buf.c 
b/firmware/libcommon/source/usb_buf.c
index b6ecd54..b97eb9c 100644
--- a/firmware/libcommon/source/usb_buf.c
+++ b/firmware/libcommon/source/usb_buf.c
@@ -101,5 +101,6 @@
for (i = 0; i < ARRAY_SIZE(usb_buffered_ep); i++) {
struct usb_buffered_ep *ep = &usb_buffered_ep[i];
INIT_LLIST_HEAD(&ep->queue);
+   ep->ep = i;
}
 }

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Id147e24d9d50c274fec963f00494cb20e2360b33
Gerrit-Change-Number: 16600
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in simtrace2[master]: card_emu: Avoid recursive calls to card_set_state()

2019-12-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16602 )


Change subject: card_emu: Avoid recursive calls to card_set_state()
..

card_emu: Avoid recursive calls to card_set_state()

A function that is called to set the state should not in itself
contain logic to issue further state changes.

Let's shift the related block out to the end of card_emu_io_statechg(),
which is the only source of card_set_state() calls for the
WAIT_{POWER,CLK,RST} states anyway.

As an added benefit, the block of statements is now also executed if
there's no state change - something that was prevented by the
"if old == new" state guard at the top of card_set_state().  I believe
this may help us to cover more (non-standard) card activation sequences.

Change-Id: Ieefa1807099eb234cfd994bca83caaa0dcc919b6
---
M firmware/libcommon/source/card_emu.c
1 file changed, 9 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/02/16602/1

diff --git a/firmware/libcommon/source/card_emu.c 
b/firmware/libcommon/source/card_emu.c
index f53b3df..66932af 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -429,13 +429,6 @@
case ISO_S_WAIT_RST:
/* disable Rx and Tx of UART */
card_emu_uart_enable(ch->uart_chan, 0);
-   /* check end activation state (only necessary if the reader to 
not respect the activation sequence) */
-   if (ch->vcc_active && ch->clocked && !ch->in_reset) {
-   /* enable the TC/ETU counter once reset has been 
released */
-   tc_etu_enable(ch->tc_chan);
-   /* prepare to send the ATR */
-   card_set_state(ch, ISO_S_WAIT_ATR);
-   }
break;
case ISO_S_WAIT_ATR:
/* Reset to initial Fi / Di ratio */
@@ -1114,6 +1107,15 @@
ch->in_reset = active;
break;
}
+
+   /* check end activation state (only necessary if the reader to
+* not respect the activation sequence) */
+   if (ch->vcc_active && ch->clocked && !ch->in_reset) {
+   /* enable the TC/ETU counter once reset has been released */
+   tc_etu_enable(ch->tc_chan);
+   /* prepare to send the ATR */
+   card_set_state(ch, ISO_S_WAIT_ATR);
+   }
 }

 /* User sets a new ATR to be returned during next card reset */

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Ieefa1807099eb234cfd994bca83caaa0dcc919b6
Gerrit-Change-Number: 16602
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in simtrace2[master]: usb_buf: Actually limit queue to 3 elements, not 4

2019-12-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16598 )

Change subject: usb_buf: Actually limit queue to 3 elements, not 4
..


Patch Set 1: Code-Review+2


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Ic5fb164f2dfd1c293c51bee8184fc34552267a54
Gerrit-Change-Number: 16598
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: laforge 
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Sun, 15 Dec 2019 16:29:34 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in simtrace2[master]: usb_buf: Properly initialize buffered_endpoint->ep number

2019-12-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16600 )

Change subject: usb_buf: Properly initialize buffered_endpoint->ep number
..


Patch Set 1: Code-Review+2


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Id147e24d9d50c274fec963f00494cb20e2360b33
Gerrit-Change-Number: 16600
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: laforge 
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Sun, 15 Dec 2019 16:29:50 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in simtrace2[master]: usb_buf: Actually limit queue to 3 elements, not 4

2019-12-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16598 )

Change subject: usb_buf: Actually limit queue to 3 elements, not 4
..

usb_buf: Actually limit queue to 3 elements, not 4

In Change-ID Ie15183f16b22193ffdaf01845db2eae4c7f43c17 we wanted
to limit the number of queue elements to 3, but actually implemented 4.

Change-Id: Ic5fb164f2dfd1c293c51bee8184fc34552267a54
---
M firmware/libcommon/source/usb_buf.c
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/firmware/libcommon/source/usb_buf.c 
b/firmware/libcommon/source/usb_buf.c
index 7892d6e..b6ecd54 100644
--- a/firmware/libcommon/source/usb_buf.c
+++ b/firmware/libcommon/source/usb_buf.c
@@ -80,7 +80,7 @@
/* no need for irqsafe operation, as the usb_tx_queue is
 * processed only by the main loop context */

-   if (ep->queue_len > USB_MAX_QLEN) {
+   if (ep->queue_len >= USB_MAX_QLEN) {
struct msgb *evict;
/* free the first pending buffer in the queue */
TRACE_INFO("EP%02x: dropping first queue element (qlen=%u)\r\n",

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Ic5fb164f2dfd1c293c51bee8184fc34552267a54
Gerrit-Change-Number: 16598
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in simtrace2[master]: pseudo_talloc: Increment number of buffers from 10 to 20

2019-12-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16604 )


Change subject: pseudo_talloc: Increment number of buffers from 10 to 20
..

pseudo_talloc: Increment number of buffers from 10 to 20

We need at least one per IN/IRQ endpoint, as well as at least 3 for
every OUT endpoint.  Plus some more depending on the application,
in case of cardem there could be one in uart_tx and one in uart_rx.

So for cardem, it should be 7 per slot, resulting 14 for dual-slot
devices like OWHW and QMOD.

Given that we have plenty of RAM available (utilization up from 49%
to 56% with this change), we can be on the comfortable size and
easily have 20 buffers for now.

Future MITM / triple-play applications likely need more.

Change-Id: I022ba3bb3e1f5fd0c364aafe1a23f8fd9b2d8499
Related: OS#4251
---
M firmware/libcommon/source/pseudo_talloc.c
1 file changed, 3 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/04/16604/1

diff --git a/firmware/libcommon/source/pseudo_talloc.c 
b/firmware/libcommon/source/pseudo_talloc.c
index 7c452b3..3407a59 100644
--- a/firmware/libcommon/source/pseudo_talloc.c
+++ b/firmware/libcommon/source/pseudo_talloc.c
@@ -22,7 +22,9 @@
 #include "utils.h"
 #include 

-#define NUM_RCTX_SMALL 10
+/* TODO: this number should dynamically scale. We need at least one per IN/IRQ 
endpoint,
+ * as well as at least 3 for every OUT endpoint.  Plus some more depending on 
the application */
+#define NUM_RCTX_SMALL 20
 #define RCTX_SIZE_SMALL 348

 static uint8_t msgb_data[NUM_RCTX_SMALL][RCTX_SIZE_SMALL] 
__attribute__((aligned(sizeof(long;

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I022ba3bb3e1f5fd0c364aafe1a23f8fd9b2d8499
Gerrit-Change-Number: 16604
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in simtrace2[master]: card_emu: Initialize PTSS state every time we start PTS

2019-12-15 Thread laforge
Hello Jenkins Builder,

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

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

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

Change subject: card_emu: Initialize PTSS state every time we start PTS
..

card_emu: Initialize PTSS state every time we start PTS

Let's shift the responsibility from the caller side to the calee side.

Change-Id: I39661ca93c87b2e2071765f69578eec5aaf90ce4
---
M firmware/libcommon/source/card_emu.c
1 file changed, 2 insertions(+), 4 deletions(-)


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I39661ca93c87b2e2071765f69578eec5aaf90ce4
Gerrit-Change-Number: 16601
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in simtrace2[master]: card_emu: Remove extraneous initialization of ch->pts.state

2019-12-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16605 )


Change subject: card_emu: Remove extraneous initialization of ch->pts.state
..

card_emu: Remove extraneous initialization of ch->pts.state

ch->pts.state is initialized every time we enter ISO_S_WAIT_TPDU
state, so there's no need to reset it at other locations. KISS.

Change-Id: I5ff8b2671c3c893cc5f6542d48b65487ae8c5be1
---
M firmware/libcommon/source/card_emu.c
1 file changed, 0 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/05/16605/1

diff --git a/firmware/libcommon/source/card_emu.c 
b/firmware/libcommon/source/card_emu.c
index ac28805..f9c3673 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -240,8 +240,6 @@

tc_etu_disable(ch->tc_chan);

-   ch->tpdu.state = TPDU_S_WAIT_CLA;
-
/* release any buffers we may still own */
if (ch->uart_tx_msg) {
usb_buf_free(ch->uart_tx_msg);

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I5ff8b2671c3c893cc5f6542d48b65487ae8c5be1
Gerrit-Change-Number: 16605
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in simtrace2[master]: USBD_HAL: Don't disable UDP peripheral clock on suspend

2019-12-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16599 )

Change subject: USBD_HAL: Don't disable UDP peripheral clock on suspend
..


Patch Set 1: Code-Review+2


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I2169e2140762b37661f4567bb148326afd85cddc
Gerrit-Change-Number: 16599
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sun, 15 Dec 2019 16:48:52 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in simtrace2[master]: card_emu: Remove extraneous code

2019-12-15 Thread laforge
laforge has uploaded a new patch set (#3). ( 
https://gerrit.osmocom.org/c/simtrace2/+/16603 )

Change subject: card_emu: Remove extraneous code
..

card_emu: Remove extraneous code

card_set_state(ch, ISO_S_WAIT_ATR) internally calls tc_etu_enable(),
so there's no need for the caller to do the same, too.

Change-Id: I2a2b4d64c40264623313a867957ffcefe57748f9
---
M firmware/libcommon/source/card_emu.c
1 file changed, 1 insertion(+), 3 deletions(-)


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I2a2b4d64c40264623313a867957ffcefe57748f9
Gerrit-Change-Number: 16603
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in simtrace2[master]: card_emu: Avoid recursive calls to card_set_state()

2019-12-15 Thread laforge
laforge has uploaded a new patch set (#3). ( 
https://gerrit.osmocom.org/c/simtrace2/+/16602 )

Change subject: card_emu: Avoid recursive calls to card_set_state()
..

card_emu: Avoid recursive calls to card_set_state()

A function that is called to set the state should not in itself
contain logic to issue further state changes.

Let's shift the related block out to the end of card_emu_io_statechg(),
which is the only source of card_set_state() calls for the
WAIT_{POWER,CLK,RST} states anyway.

As an added benefit, the block of statements is now also executed if
there's no state change - something that was prevented by the
"if old == new" state guard at the top of card_set_state().  I believe
this may help us to cover more (non-standard) card activation sequences.

Change-Id: Ieefa1807099eb234cfd994bca83caaa0dcc919b6
---
M firmware/libcommon/source/card_emu.c
1 file changed, 9 insertions(+), 7 deletions(-)


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Ieefa1807099eb234cfd994bca83caaa0dcc919b6
Gerrit-Change-Number: 16602
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in simtrace2[master]: card_emu: Initialize PTSS state every time we start PTS

2019-12-15 Thread laforge
Hello Jenkins Builder,

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

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

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

Change subject: card_emu: Initialize PTSS state every time we start PTS
..

card_emu: Initialize PTSS state every time we start PTS

Let's shift the responsibility from the caller side to the calee side.

Change-Id: I39661ca93c87b2e2071765f69578eec5aaf90ce4
---
M firmware/libcommon/source/card_emu.c
1 file changed, 2 insertions(+), 4 deletions(-)


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I39661ca93c87b2e2071765f69578eec5aaf90ce4
Gerrit-Change-Number: 16601
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in simtrace2[master]: card_emu: Remove extraneous initialization of ch->pts.state

2019-12-15 Thread laforge
laforge has uploaded a new patch set (#2). ( 
https://gerrit.osmocom.org/c/simtrace2/+/16605 )

Change subject: card_emu: Remove extraneous initialization of ch->pts.state
..

card_emu: Remove extraneous initialization of ch->pts.state

ch->pts.state is initialized every time we enter ISO_S_WAIT_TPDU
state, so there's no need to reset it at other locations. KISS.

Change-Id: I5ff8b2671c3c893cc5f6542d48b65487ae8c5be1
---
M firmware/libcommon/source/card_emu.c
1 file changed, 0 insertions(+), 2 deletions(-)


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I5ff8b2671c3c893cc5f6542d48b65487ae8c5be1
Gerrit-Change-Number: 16605
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in simtrace2[master]: pseudo_talloc: Increment number of buffers from 10 to 20

2019-12-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16604 )

Change subject: pseudo_talloc: Increment number of buffers from 10 to 20
..


Patch Set 1: Code-Review+2


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I022ba3bb3e1f5fd0c364aafe1a23f8fd9b2d8499
Gerrit-Change-Number: 16604
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sun, 15 Dec 2019 16:53:53 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in simtrace2[master]: card_emu: Factor out card_handle_reset() from card_emu_init()

2019-12-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16582 )

Change subject: card_emu: Factor out card_handle_reset() from card_emu_init()
..


Set Ready For Review


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I0954d192d001a3af5592010cc84a3a22aaf4b030
Gerrit-Change-Number: 16582
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sun, 15 Dec 2019 16:54:55 +
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in simtrace2[master]: cardem: RST resets all state (including release of buffers)

2019-12-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16584 )

Change subject: cardem: RST resets all state (including release of buffers)
..


Set Ready For Review


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I66eca6afe4ff7d900c5b75df1e3ec6d52f6ef214
Gerrit-Change-Number: 16584
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sun, 15 Dec 2019 16:54:51 +
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in simtrace2[master]: cardem: Move card_emu_io_statechg() calls out of interrupt context

2019-12-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16583 )

Change subject: cardem: Move card_emu_io_statechg() calls out of interrupt 
context
..


Patch Set 5: Code-Review+2


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I3983078396538f32bdff55611c41d2163be4d796
Gerrit-Change-Number: 16583
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sun, 15 Dec 2019 16:54:24 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in simtrace2[master]: card_emu: Initialize PTSS state every time we start PTS

2019-12-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16601 )

Change subject: card_emu: Initialize PTSS state every time we start PTS
..


Patch Set 3: Code-Review+2


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I39661ca93c87b2e2071765f69578eec5aaf90ce4
Gerrit-Change-Number: 16601
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sun, 15 Dec 2019 16:54:47 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in simtrace2[master]: card_emu: Factor out card_handle_reset() from card_emu_init()

2019-12-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16582 )

Change subject: card_emu: Factor out card_handle_reset() from card_emu_init()
..

card_emu: Factor out card_handle_reset() from card_emu_init()

Let's move all initialization of state that may change at runtime
to a separate function: card_handle_reset().

This has the advantage that the related function may also be called
at later/other instances, not just during initialization of card_emu.

Change-Id: I0954d192d001a3af5592010cc84a3a22aaf4b030
Related: OS#4251
---
M firmware/libcommon/source/card_emu.c
1 file changed, 9 insertions(+), 3 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/firmware/libcommon/source/card_emu.c 
b/firmware/libcommon/source/card_emu.c
index f95f5d1..7ce10a8 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -1,6 +1,6 @@
 /* ISO7816-3 state machine for the card side
  *
- * (C) 2010-2017 by Harald Welte 
+ * (C) 2010-2019 by Harald Welte 
  * (C) 2018 by sysmocom -s.f.m.c. GmbH, Author: Kevin Redon 

  *
  * This program is free software; you can redistribute it and/or modify
@@ -233,6 +233,13 @@
} stats;
 };

+/* reset all the 'dynamic' state of the card handle to the initial/default 
values */
+static void card_handle_reset(struct card_handle *ch)
+{
+   ch->pts.state = PTS_S_WAIT_REQ_PTSS;
+   ch->tpdu.state = TPDU_S_WAIT_CLA;
+}
+
 struct llist_head *card_emu_get_uart_tx_queue(struct card_handle *ch)
 {
return &ch->uart_tx_queue;
@@ -1189,8 +1196,7 @@
ch->atr.len = sizeof(default_atr);
memcpy(ch->atr.atr, default_atr, ch->atr.len);

-   ch->pts.state = PTS_S_WAIT_REQ_PTSS;
-   ch->tpdu.state = TPDU_S_WAIT_CLA;
+   card_handle_reset(ch);

tc_etu_init(ch->tc_chan, ch);


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I0954d192d001a3af5592010cc84a3a22aaf4b030
Gerrit-Change-Number: 16582
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in simtrace2[master]: pseudo_talloc: Increment number of buffers from 10 to 20

2019-12-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16604 )

Change subject: pseudo_talloc: Increment number of buffers from 10 to 20
..

pseudo_talloc: Increment number of buffers from 10 to 20

We need at least one per IN/IRQ endpoint, as well as at least 3 for
every OUT endpoint.  Plus some more depending on the application,
in case of cardem there could be one in uart_tx and one in uart_rx.

So for cardem, it should be 7 per slot, resulting 14 for dual-slot
devices like OWHW and QMOD.

Given that we have plenty of RAM available (utilization up from 49%
to 56% with this change), we can be on the comfortable size and
easily have 20 buffers for now.

Future MITM / triple-play applications likely need more.

Change-Id: I022ba3bb3e1f5fd0c364aafe1a23f8fd9b2d8499
Related: OS#4251
---
M firmware/libcommon/source/pseudo_talloc.c
1 file changed, 3 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/firmware/libcommon/source/pseudo_talloc.c 
b/firmware/libcommon/source/pseudo_talloc.c
index 7c452b3..3407a59 100644
--- a/firmware/libcommon/source/pseudo_talloc.c
+++ b/firmware/libcommon/source/pseudo_talloc.c
@@ -22,7 +22,9 @@
 #include "utils.h"
 #include 

-#define NUM_RCTX_SMALL 10
+/* TODO: this number should dynamically scale. We need at least one per IN/IRQ 
endpoint,
+ * as well as at least 3 for every OUT endpoint.  Plus some more depending on 
the application */
+#define NUM_RCTX_SMALL 20
 #define RCTX_SIZE_SMALL 348

 static uint8_t msgb_data[NUM_RCTX_SMALL][RCTX_SIZE_SMALL] 
__attribute__((aligned(sizeof(long;

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I022ba3bb3e1f5fd0c364aafe1a23f8fd9b2d8499
Gerrit-Change-Number: 16604
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in simtrace2[master]: cardem: Move card_emu_io_statechg() calls out of interrupt context

2019-12-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16583 )

Change subject: cardem: Move card_emu_io_statechg() calls out of interrupt 
context
..

cardem: Move card_emu_io_statechg() calls out of interrupt context

So far, we called card_emu_io_statechg() from interrupt context, which
was safe with the current code.  However, as we want to trigger a more
comprehensive reset of data structures, including the flushing of
message queues, it is best to shift this processing from interrupt
context to main loop context.

Change-Id: I3983078396538f32bdff55611c41d2163be4d796
Related: OS#4251
---
M firmware/libcommon/source/mode_cardemu.c
1 file changed, 51 insertions(+), 28 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/firmware/libcommon/source/mode_cardemu.c 
b/firmware/libcommon/source/mode_cardemu.c
index 1669c2d..1d074cb 100644
--- a/firmware/libcommon/source/mode_cardemu.c
+++ b/firmware/libcommon/source/mode_cardemu.c
@@ -60,8 +60,13 @@
uint8_t ep_in;
uint8_t ep_int;
const Pin pin_insert;
+#ifdef DETECT_VCC_BY_ADC
uint32_t vcc_uv;
-   uint32_t vcc_uv_last;
+#endif
+   bool vcc_active;
+   bool vcc_active_last;
+   bool rst_active;
+   bool rst_active_last;
 };

 struct cardem_inst cardem_inst[] = {
@@ -261,7 +266,7 @@

 #ifdef DETECT_VCC_BY_ADC

-static int adc_triggered = 0;
+static volatile int adc_triggered = 0;
 static int adc_sam3s_reva_errata = 0;

 static int card_vcc_adc_init(void)
@@ -313,18 +318,10 @@

 static void process_vcc_adc(struct cardem_inst *ci)
 {
-   if (ci->vcc_uv >= VCC_UV_THRESH_3V &&
-   ci->vcc_uv_last < VCC_UV_THRESH_3V) {
-   card_emu_io_statechg(ci->ch, CARD_IO_VCC, 1);
-   /* FIXME do this for real */
-   card_emu_io_statechg(ci->ch, CARD_IO_CLK, 1);
-   } else if (ci->vcc_uv < VCC_UV_THRESH_3V &&
-ci->vcc_uv_last >= VCC_UV_THRESH_3V) {
-   /* FIXME do this for real */
-   card_emu_io_statechg(ci->ch, CARD_IO_CLK, 0);
-   card_emu_io_statechg(ci->ch, CARD_IO_VCC, 0);
-   }
-   ci->vcc_uv_last = ci->vcc_uv;
+   if (ci->vcc_uv >= VCC_UV_THRESH_3V)
+   ci->vcc_active = true;
+   else
+   ci->vcc_active = false;
 }

 void ADC_IrqHandler(void)
@@ -347,44 +344,54 @@
cardem_inst[0].vcc_uv = adc2uv(val);
process_vcc_adc(&cardem_inst[0]);
ADC->ADC_CR |= ADC_CR_START;
+   adc_triggered = 1;
}
 }
 #endif /* DETECT_VCC_BY_ADC */

+
+/* called from main loop; dispatches card I/O state changes to card_emu from 
main loop */
+static void process_io_statechg(struct cardem_inst *ci)
+{
+   if (ci->vcc_active != ci->vcc_active_last) {
+   card_emu_io_statechg(ci->ch, CARD_IO_VCC, ci->vcc_active);
+   /* FIXME do this for real */
+   card_emu_io_statechg(ci->ch, CARD_IO_CLK, ci->vcc_active);
+   ci->vcc_active_last = ci->vcc_active;
+   }
+
+   if (ci->rst_active != ci->rst_active_last) {
+   card_emu_io_statechg(ci->ch, CARD_IO_RST, ci->rst_active);
+   ci->rst_active_last = ci->rst_active;
+   }
+}
+
 /***
  * Core USB  / main loop integration
  ***/

 static void usim1_rst_irqhandler(const Pin *pPin)
 {
-   bool active = PIO_Get(&pin_usim1_rst) ? false : true;
-   card_emu_io_statechg(cardem_inst[0].ch, CARD_IO_RST, active);
+   cardem_inst[0].rst_active = PIO_Get(&pin_usim1_rst) ? false : true;
 }

 #ifndef DETECT_VCC_BY_ADC
 static void usim1_vcc_irqhandler(const Pin *pPin)
 {
-   bool active = PIO_Get(&pin_usim1_vcc) ? true : false;
-   card_emu_io_statechg(cardem_inst[0].ch, CARD_IO_VCC, active);
-   /* FIXME do this for real */
-   card_emu_io_statechg(cardem_inst[0].ch, CARD_IO_CLK, active);
+   cardem_inst[0].vcc_active = PIO_Get(&pin_usim1_vcc) ? true : false;
 }
 #endif /* !DETECT_VCC_BY_ADC */

 #ifdef CARDEMU_SECOND_UART
 static void usim2_rst_irqhandler(const Pin *pPin)
 {
-   bool active = PIO_Get(&pin_usim2_rst) ? false : true;
-   card_emu_io_statechg(cardem_inst[1].ch, CARD_IO_RST, active);
+   cardem_inst[1].rst_active = PIO_Get(&pin_usim2_rst) ? false : true;
 }

 #ifndef DETECT_VCC_BY_ADC
 static void usim2_vcc_irqhandler(const Pin *pPin)
 {
-   bool active = PIO_Get(&pin_usim2_vcc) ? true : false;
-   card_emu_io_statechg(cardem_inst[1].ch, CARD_IO_VCC, active);
-   /* FIXME do this for real */
-   card_emu_io_statechg(cardem_inst[1].ch, CARD_IO_CLK, active);
+   cardem_inst[1].vcc_active = PIO_Get(&pin_usim2_vcc) ? true : false;
 }
 #endif /* !DETECT_VCC_BY_ADC */
 #endif /* CA

Change in simtrace2[master]: USBD_HAL: Don't disable UDP peripheral clock on suspend

2019-12-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16599 )

Change subject: USBD_HAL: Don't disable UDP peripheral clock on suspend
..

USBD_HAL: Don't disable UDP peripheral clock on suspend

Change-Id: I2169e2140762b37661f4567bb148326afd85cddc
Closes: OS#4329
---
M firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
1 file changed, 4 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c 
b/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
index 3fe3270..0eccc65 100644
--- a/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
+++ b/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
@@ -1687,7 +1687,10 @@
 /* The device enters the Suspended state */
 UDP_DisableTransceiver();
 UDP_DisableUsbClock();
-UDP_DisablePeripheralClock();
+/* Don't disable peripheral clock; this somehow breaks completion of any 
IN transfers
+ * that have already been written to the peripheral, and which we expect 
to complete
+ * after resume */
+//UDP_DisablePeripheralClock();
 }

 /**

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I2169e2140762b37661f4567bb148326afd85cddc
Gerrit-Change-Number: 16599
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in simtrace2[master]: cardem: RST resets all state (including release of buffers)

2019-12-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16584 )

Change subject: cardem: RST resets all state (including release of buffers)
..

cardem: RST resets all state (including release of buffers)

When the Modem is asserting RST, the emulated card should set all
of its state back to default/initial values and release any buffers
it may still hold in its state.

Change-Id: I66eca6afe4ff7d900c5b75df1e3ec6d52f6ef214
Related: OS#4251
---
M firmware/libcommon/source/card_emu.c
1 file changed, 19 insertions(+), 2 deletions(-)

Approvals:
  laforge: Looks good to me, approved; Verified



diff --git a/firmware/libcommon/source/card_emu.c 
b/firmware/libcommon/source/card_emu.c
index 7ce10a8..63bf0d3 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -236,8 +236,25 @@
 /* reset all the 'dynamic' state of the card handle to the initial/default 
values */
 static void card_handle_reset(struct card_handle *ch)
 {
+   struct msgb *msg;
+
+   tc_etu_disable(ch->tc_chan);
+
ch->pts.state = PTS_S_WAIT_REQ_PTSS;
ch->tpdu.state = TPDU_S_WAIT_CLA;
+
+   /* release any buffers we may still own */
+   if (ch->uart_tx_msg) {
+   usb_buf_free(ch->uart_tx_msg);
+   ch->uart_tx_msg = NULL;
+   }
+   if (ch->uart_rx_msg) {
+   usb_buf_free(ch->uart_rx_msg);
+   ch->uart_rx_msg = NULL;
+   }
+   while ((msg = msgb_dequeue(&ch->uart_tx_queue))) {
+   usb_buf_free(msg);
+   }
 }

 struct llist_head *card_emu_get_uart_tx_queue(struct card_handle *ch)
@@ -1062,7 +1079,7 @@
case CARD_IO_VCC:
if (active == 0 && ch->vcc_active == 1) {
TRACE_INFO("%u: VCC deactivated\r\n", ch->num);
-   tc_etu_disable(ch->tc_chan);
+   card_handle_reset(ch);
card_set_state(ch, ISO_S_WAIT_POWER);
} else if (active == 1 && ch->vcc_active == 0) {
TRACE_INFO("%u: VCC activated\r\n", ch->num);
@@ -1091,7 +1108,7 @@
}
} else if (active && !ch->in_reset) {
TRACE_INFO("%u: RST asserted\r\n", ch->num);
-   tc_etu_disable(ch->tc_chan);
+   card_handle_reset(ch);
}
ch->in_reset = active;
break;

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I66eca6afe4ff7d900c5b75df1e3ec6d52f6ef214
Gerrit-Change-Number: 16584
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in simtrace2[master]: cardem: RST resets all state (including release of buffers)

2019-12-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16584 )

Change subject: cardem: RST resets all state (including release of buffers)
..


Patch Set 5: Verified+1


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I66eca6afe4ff7d900c5b75df1e3ec6d52f6ef214
Gerrit-Change-Number: 16584
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sun, 15 Dec 2019 17:00:28 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in simtrace2[master]: usb_buf: Properly initialize buffered_endpoint->ep number

2019-12-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16600 )

Change subject: usb_buf: Properly initialize buffered_endpoint->ep number
..

usb_buf: Properly initialize buffered_endpoint->ep number

The number is used only in print statements, and it's always '0' so far.

Change-Id: Id147e24d9d50c274fec963f00494cb20e2360b33
---
M firmware/libcommon/source/usb_buf.c
1 file changed, 1 insertion(+), 0 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/firmware/libcommon/source/usb_buf.c 
b/firmware/libcommon/source/usb_buf.c
index b6ecd54..b97eb9c 100644
--- a/firmware/libcommon/source/usb_buf.c
+++ b/firmware/libcommon/source/usb_buf.c
@@ -101,5 +101,6 @@
for (i = 0; i < ARRAY_SIZE(usb_buffered_ep); i++) {
struct usb_buffered_ep *ep = &usb_buffered_ep[i];
INIT_LLIST_HEAD(&ep->queue);
+   ep->ep = i;
}
 }

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Id147e24d9d50c274fec963f00494cb20e2360b33
Gerrit-Change-Number: 16600
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in libosmocore[master]: libosmocore libusb integration

2019-12-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/16606 )


Change subject: libosmocore libusb integration
..

libosmocore libusb integration

Osmocom applications typically use libosmocore select.[ch] event loop
code as their main event dispatch mechanism.  When they want to deal
with libusb in a non-blocking/asynchronous way, they need to integrate
libusb into that select().

The new libosmousb is doing exactly that: Providing a shared utility
library for Osmocom programs that wish to use libusb.  This is useful
for example in simtrace2 host utilitie as well as osmo-e1d.

Change-Id: I656a1a38cbb5b1f3a9145d2869d3b4d0adefcae3
---
M Makefile.am
M configure.ac
M debian/control
A debian/libosmousb0.install
M include/Makefile.am
A include/osmocom/usb/libusb.h
A libosmousb.pc.in
A src/usb/Makefile.am
A src/usb/osmo_libusb.c
9 files changed, 210 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/06/16606/1

diff --git a/Makefile.am b/Makefile.am
index 7b6ba0a..7390f98 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,11 +1,12 @@
 ACLOCAL_AMFLAGS = -I m4

 AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
-SUBDIRS = include src src/vty src/codec src/gsm src/coding src/gb src/ctrl 
src/sim src/pseudotalloc utils tests
+SUBDIRS = include src src/vty src/codec src/gsm src/coding src/gb src/ctrl 
src/sim src/pseudotalloc src/usb utils tests

 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libosmocore.pc libosmocodec.pc libosmovty.pc libosmogsm.pc \
-libosmogb.pc libosmoctrl.pc libosmocoding.pc libosmosim.pc
+libosmogb.pc libosmoctrl.pc libosmocoding.pc libosmosim.pc \
+libosmousb.pc

 aclocaldir = $(datadir)/aclocal
 dist_aclocal_DATA = m4/osmo_ac_code_coverage.m4 \
diff --git a/configure.ac b/configure.ac
index 060d081..e45ec9f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -146,6 +146,19 @@
 AM_CONDITIONAL(ENABLE_PCSC, test "x$ENABLE_PCSC" = "xyes")
 AC_SUBST(ENABLE_PCSC)

+AC_ARG_ENABLE([libusb], [AS_HELP_STRING([--disable-libusb], [Build without 
libusb support])],
+[
+ENABLE_LIBUSB=$enableval
+],
+[
+ENABLE_LIBUSB="yes"
+])
+AS_IF([test "x$ENABLE_LIBUSB" = "xyes"], [
+   PKG_CHECK_MODULES(LIBUSB, libusb-1.0)
+])
+AM_CONDITIONAL(ENABLE_LIBUSB, test "x$ENABLE_LIBUSB" = "xyes")
+AC_SUBST(ENABLE_LIBUSB)
+
 AC_ARG_ENABLE([gnutls], [AS_HELP_STRING([--disable-gnutls], [Do not use GnuTLS 
fallback for missing getrandom()])],
[ENABLE_GNUTLS=$enableval], [ENABLE_GNUTLS="yes"])
 AM_CONDITIONAL(ENABLE_GNUTLS, test x"$ENABLE_GNUTLS" = x"yes")
@@ -398,12 +411,14 @@
libosmogb.pc
libosmoctrl.pc
libosmosim.pc
+   libosmousb.pc
include/Makefile
src/Makefile
src/vty/Makefile
src/codec/Makefile
src/coding/Makefile
src/sim/Makefile
+   src/usb/Makefile
src/gsm/Makefile
src/gb/Makefile
src/ctrl/Makefile
diff --git a/debian/control b/debian/control
index cf7a853..d2c232f 100644
--- a/debian/control
+++ b/debian/control
@@ -34,6 +34,7 @@
  libosmovty4 (= ${binary:Version}),
  libosmoctrl0 (= ${binary:Version}),
  libosmosim0 (= ${binary:Version}),
+ libosmousb0 (= ${binary:Version}),
  ${misc:Depends}
 Description: Open Source MObile COMmunications CORE library (metapackage)
  The libraries provided by this package contain various utility functions.
@@ -293,6 +294,23 @@
  .
  The libosmosim library in particular contains routines for SIM card access.

+Package: libosmousb0
+Section: libs
+Architecture: any
+Multi-Arch: same
+Depends: ${shlibs:Depends},
+ ${misc:Depends}
+Pre-Depends: ${misc:Pre-Depends}
+Description: Osmo USB library
+ This is part of the libosmocore "meta"-library. The libosmocore library
+ contains various utility functions that were originally developed as part of
+ the OpenBSC project, but which are of a more generic nature and thus useful to
+ (at least) other programs that are developed in the sphere of Free Software /
+ Open Source mobile communication.
+ .
+ The libosmosub library in particular contains routines for USB device access
+ via libusb-1.0, integrated into the libosmocore select event loop.
+
 Package: libosmocore-dev
 Architecture: any
 Multi-Arch: same
diff --git a/debian/libosmousb0.install b/debian/libosmousb0.install
new file mode 100644
index 000..4031b9f
--- /dev/null
+++ b/debian/libosmousb0.install
@@ -0,0 +1 @@
+usr/lib/*/libosmousb*.so.*
diff --git a/include/Makefile.am b/include/Makefile.am
index d76addd..dc6eaa7 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -164,6 +164,11 @@
   osmocom/ctrl/control_vty.h
 endif

+if ENABLE_LIBUSB
+nobase_include_HEADERS += \
+ osmocom/usb/libusb.h
+endif
+
 noinst_HEADERS = \
   

Change in libosmocore[master]: usb: Import a variety of libusb utility functions from simtrace

2019-12-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/16607 )


Change subject: usb: Import a variety of libusb utility functions from simtrace
..

usb: Import a variety of libusb utility functions from simtrace

Those functions were originally developed as part of simtrace; let's
import them to libosmousb as they are truly generic.

Change-Id: I2c18b938e4e1ea5b8a521a386f00db3a7389e47a
---
M include/osmocom/usb/libusb.h
M src/usb/osmo_libusb.c
2 files changed, 384 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/07/16607/1

diff --git a/include/osmocom/usb/libusb.h b/include/osmocom/usb/libusb.h
index 7f10f74..5b01847 100644
--- a/include/osmocom/usb/libusb.h
+++ b/include/osmocom/usb/libusb.h
@@ -1,6 +1,77 @@
 #pragma once
+/* libusb utilities
+ *
+ * (C) 2010-2019 by Harald Welte 
+ *
+ * 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 

+#define USB_MAX_PATH_LEN 20
+
+struct dev_id {
+   uint16_t vendor_id;
+   uint16_t product_id;
+};
+
+/* structure describing a single matching interface found */
+struct usb_interface_match {
+   /* libusb device E*/
+   libusb_device *usb_dev;
+   /* Vendor ID of the device running matching interface */
+   uint16_t vendor;
+   /* Product ID of the device running matching interface */
+   uint16_t product;
+   /* USB Bus Address */
+   uint8_t addr;
+   /* physical path */
+   char path[USB_MAX_PATH_LEN];
+   /* configuration of matching interface */
+   uint8_t configuration;
+   /* interface number of matching interface */
+   uint8_t interface;
+   /* altsetting of matching interface */
+   uint8_t altsetting;
+   /* bInterfaceClass of matching interface */
+   uint8_t class;
+   /* bInterfaceSubClass of matching interface */
+   uint8_t sub_class;
+   /* bInterfaceProtocol of matching interface */
+   uint8_t protocol;
+   /* index of string descriptor of matching interface */
+   uint8_t string_idx;
+};
+
+
+char *osmo_libusb_dev_get_path_buf(char *buf, size_t bufsize, libusb_device 
*dev);
+char *osmo_libusb_dev_get_path_c(void *ctx, libusb_device *dev);
+
+libusb_device **osmo_libusb_find_matching_usb_devs(void *ctx, struct 
libusb_context *luctx,
+  const struct dev_id 
*dev_ids);
+
+int osmo_libusb_dev_find_matching_interfaces(libusb_device *dev, int class, 
int sub_class,
+int protocol, struct 
usb_interface_match *out,
+unsigned int out_len);
+
+libusb_device_handle *osmo_libusb_open_claim_interface(void *ctx, 
libusb_context *luctx,
+   const struct 
usb_interface_match *ifm);
+
+int osmo_libusb_get_ep_addrs(libusb_device_handle *devh, unsigned int if_num,
+uint8_t *out, uint8_t *in, uint8_t *irq);
+
+
 int osmo_libusb_init(libusb_context **luctx);
 void osmo_libusb_exit(libusb_context *luctx);
diff --git a/src/usb/osmo_libusb.c b/src/usb/osmo_libusb.c
index 79ab0ff..c8633b3 100644
--- a/src/usb/osmo_libusb.c
+++ b/src/usb/osmo_libusb.c
@@ -1,6 +1,6 @@
 /* libosmocore integration with libusb-1.0
  *
- * (C) 2019 by Harald Welte 
+ * (C) 2019-2019 by Harald Welte 
  * All Rights Reserved.
  *
  * SPDX-License-Identifier: GPL-2.0+
@@ -33,6 +33,8 @@

 #include 
 
+#include 
+
 /***
  * logging integration
  ***/
@@ -104,7 +106,317 @@
talloc_free(ofd);
 }

+/***
+ * utility functions
+ ***/

+/*! obtain the string representation of the USB device path of given device.
+ *  \param[out] buf Output string buffer
+ *  \param[in] bufsize Size of output string buffer in bytes
+ *  \param[in] dev USB device whose bus path we want to obtain
+ *  \returns pointer to 'buf' in case of success; NULL in case of error */
+char *osmo_libusb_dev_get_p

Change in libosmocore[master]: usb: Import a variety of libusb utility functions from simtrace

2019-12-15 Thread laforge
laforge has uploaded a new patch set (#2). ( 
https://gerrit.osmocom.org/c/libosmocore/+/16607 )

Change subject: usb: Import a variety of libusb utility functions from simtrace
..

usb: Import a variety of libusb utility functions from simtrace

Those functions were originally developed as part of simtrace; let's
import them to libosmousb as they are truly generic.

Change-Id: I2c18b938e4e1ea5b8a521a386f00db3a7389e47a
---
M include/osmocom/usb/libusb.h
M src/usb/osmo_libusb.c
2 files changed, 452 insertions(+), 1 deletion(-)


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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I2c18b938e4e1ea5b8a521a386f00db3a7389e47a
Gerrit-Change-Number: 16607
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: usb: Import a variety of libusb utility functions from simtrace

2019-12-15 Thread laforge
laforge has uploaded a new patch set (#3). ( 
https://gerrit.osmocom.org/c/libosmocore/+/16607 )

Change subject: usb: Import a variety of libusb utility functions from simtrace
..

usb: Import a variety of libusb utility functions from simtrace

Those functions were originally developed as part of simtrace; let's
import them to libosmousb as they are truly generic.

Change-Id: I2c18b938e4e1ea5b8a521a386f00db3a7389e47a
Related: OS#4299
---
M include/osmocom/usb/libusb.h
M src/usb/osmo_libusb.c
2 files changed, 452 insertions(+), 1 deletion(-)


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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I2c18b938e4e1ea5b8a521a386f00db3a7389e47a
Gerrit-Change-Number: 16607
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: libosmocore libusb integration

2019-12-15 Thread laforge
laforge has uploaded a new patch set (#2). ( 
https://gerrit.osmocom.org/c/libosmocore/+/16606 )

Change subject: libosmocore libusb integration
..

libosmocore libusb integration

Osmocom applications typically use libosmocore select.[ch] event loop
code as their main event dispatch mechanism.  When they want to deal
with libusb in a non-blocking/asynchronous way, they need to integrate
libusb into that select().

The new libosmousb is doing exactly that: Providing a shared utility
library for Osmocom programs that wish to use libusb.  This is useful
for example in simtrace2 host utilitie as well as osmo-e1d.

Change-Id: I656a1a38cbb5b1f3a9145d2869d3b4d0adefcae3
Closes: OS#4299
---
M Makefile.am
M configure.ac
M debian/control
A debian/libosmousb0.install
M include/Makefile.am
A include/osmocom/usb/libusb.h
A libosmousb.pc.in
A src/usb/Makefile.am
A src/usb/osmo_libusb.c
9 files changed, 210 insertions(+), 2 deletions(-)


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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I656a1a38cbb5b1f3a9145d2869d3b4d0adefcae3
Gerrit-Change-Number: 16606
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: usb: Import a variety of libusb utility functions from simtrace

2019-12-15 Thread laforge
laforge has uploaded a new patch set (#4). ( 
https://gerrit.osmocom.org/c/libosmocore/+/16607 )

Change subject: usb: Import a variety of libusb utility functions from simtrace
..

usb: Import a variety of libusb utility functions from simtrace

Those functions were originally developed as part of simtrace; let's
import them to libosmousb as they are truly generic.

Change-Id: I2c18b938e4e1ea5b8a521a386f00db3a7389e47a
Related: OS#4299
---
M include/osmocom/usb/libusb.h
M src/usb/osmo_libusb.c
2 files changed, 452 insertions(+), 1 deletion(-)


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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I2c18b938e4e1ea5b8a521a386f00db3a7389e47a
Gerrit-Change-Number: 16607
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: libosmocore libusb integration

2019-12-15 Thread laforge
Hello tnt, Jenkins Builder,

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

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

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

Change subject: libosmocore libusb integration
..

libosmocore libusb integration

Osmocom applications typically use libosmocore select.[ch] event loop
code as their main event dispatch mechanism.  When they want to deal
with libusb in a non-blocking/asynchronous way, they need to integrate
libusb into that select().

The new libosmousb is doing exactly that: Providing a shared utility
library for Osmocom programs that wish to use libusb.  This is useful
for example in simtrace2 host utilitie as well as osmo-e1d.

Change-Id: I656a1a38cbb5b1f3a9145d2869d3b4d0adefcae3
Closes: OS#4299
---
M Makefile.am
M configure.ac
M contrib/jenkins_arm.sh
M debian/control
A debian/libosmousb0.install
M include/Makefile.am
A include/osmocom/usb/libusb.h
A libosmousb.pc.in
A src/usb/Makefile.am
A src/usb/osmo_libusb.c
10 files changed, 213 insertions(+), 2 deletions(-)


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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I656a1a38cbb5b1f3a9145d2869d3b4d0adefcae3
Gerrit-Change-Number: 16606
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: tnt 
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: gprs_bssgp: Work around gcc-9 claiming "error=stringop-overflow"

2019-12-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/16608 )


Change subject: gprs_bssgp: Work around gcc-9 claiming "error=stringop-overflow"
..

gprs_bssgp: Work around gcc-9 claiming "error=stringop-overflow"

gcc-9.2.1 issues the following errror when compiling with -Werror:

In function ‘tl16v_put’,
inlined from ‘tvlv_put’ at ../../include/osmocom/gsm/tlv.h:156:9,
inlined from ‘tvlv_put’ at ../../include/osmocom/gsm/tlv.h:147:24,
inlined from ‘msgb_tvlv_put’ at ../../include/osmocom/gsm/tlv.h:223:9,
inlined from ‘bssgp_tx_paging’ at gprs_bssgp.c:1250:2:
../../include/osmocom/gsm/tlv.h:131:2: error: ‘memcpy’ reading between 128 and 
65535 bytes from a region of size 9 [-Werror=stringop-overflow=]
  131 |  memcpy(buf, val, len);
  |  ^

Unfortunately I've not been able to work around it with some nice GCC
#pragma GCC diagnostic ignored "-Wstringop-overflow"

Change-Id: I22a0c399c6c00eaf87277002096a82844c9e198e
---
M src/gb/gprs_bssgp.c
M src/gb/gprs_bssgp_bss.c
2 files changed, 3 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/08/16608/1

diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c
index 896f1c5..38794c2 100644
--- a/src/gb/gprs_bssgp.c
+++ b/src/gb/gprs_bssgp.c
@@ -1178,6 +1178,7 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Warray-bounds"
int imsi_len = gsm48_generate_mid_from_imsi(mi, dup->imsi);
+   OSMO_ASSERT(imsi_len <= GSM48_MID_MAX_SIZE);
if (imsi_len > 2)
msgb_tvlv_push(msg, BSSGP_IE_IMSI,
imsi_len-2, mi+2);
@@ -1247,6 +1248,7 @@
  * mi[131], which is wrong */
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Warray-bounds"
+   OSMO_ASSERT(imsi_len <= GSM48_MID_MAX_SIZE);
msgb_tvlv_put(msg, BSSGP_IE_IMSI, imsi_len-2, mi+2);
 #pragma GCC diagnostic pop
/* DRX Parameters */
diff --git a/src/gb/gprs_bssgp_bss.c b/src/gb/gprs_bssgp_bss.c
index f06c403..5c9d11c 100644
--- a/src/gb/gprs_bssgp_bss.c
+++ b/src/gb/gprs_bssgp_bss.c
@@ -189,6 +189,7 @@
  * mi[131], which is wrong */
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Warray-bounds"
+   OSMO_ASSERT(imsi_len <= GSM48_MID_MAX_SIZE);
/* strip the MI type and length values (2 bytes) */
if (imsi_len > 2)
msgb_tvlv_put(msg, BSSGP_IE_IMSI, imsi_len-2, mi+2);

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I22a0c399c6c00eaf87277002096a82844c9e198e
Gerrit-Change-Number: 16608
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in osmo-remsim[master]: remsim_client: Port to async libosmousb select loop

2019-12-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/16610 )


Change subject: remsim_client: Port to async libosmousb select loop
..

remsim_client: Port to async libosmousb select loop

By using the non-blocking / asynchronous libusb via the newly-
introduced libosmousb (integration to libosmocore select loop),
we can not only get a cleaner code-base, but we also get a
considerable speed-up.

In my tests with a Quectel E25 and a sysmoUSIM-SJS1 card,
I am down from 41.4s to 4.7s for the initial reading of the SIM
at start-up.

Change-Id: Ic18690b3c2cbc5e99de0665c0b68b7555433b3cd
Closes: OS#4299
Depends: libosmocore.git I656a1a38cbb5b1f3a9145d2869d3b4d0adefcae3
---
M src/simtrace2-remsim_client.c
1 file changed, 140 insertions(+), 34 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/10/16610/1

diff --git a/src/simtrace2-remsim_client.c b/src/simtrace2-remsim_client.c
index 30a9c5b..fa6b102 100644
--- a/src/simtrace2-remsim_client.c
+++ b/src/simtrace2-remsim_client.c
@@ -143,20 +143,50 @@
 }
 #endif

+static void usb_out_xfer_cb(struct libusb_transfer *xfer)
+{
+   struct msgb *msg = xfer->user_data;
+
+   switch (xfer->status) {
+   case LIBUSB_TRANSFER_COMPLETED:
+   break;
+   case LIBUSB_TRANSFER_NO_DEVICE:
+   fprintf(stderr, "USB device disappeared\n");
+   exit(23);
+   break;
+   default:
+   osmo_panic("USB OUT transfer failed, status=%u\n", 
xfer->status);
+   break;
+   }
+
+   msgb_free(msg);
+   libusb_free_transfer(xfer);
+}
+
 /*! \brief Transmit a given command to the SIMtrace2 device */
 int st_transp_tx_msg(struct st_transport *transp, struct msgb *msg)
 {
+   struct libusb_transfer *xfer;
int rc;

printf("SIMtrace <- %s\n", msgb_hexdump(msg));

-   int xfer_len;
+   xfer = libusb_alloc_transfer(0);
+   OSMO_ASSERT(xfer);
+   xfer->dev_handle = transp->usb_devh;
+   xfer->flags = 0;
+   xfer->type = LIBUSB_TRANSFER_TYPE_BULK;
+   xfer->endpoint = transp->usb_ep.out;
+   xfer->timeout = 1000;
+   xfer->user_data = msg;
+   xfer->length = msgb_length(msg);
+   xfer->buffer = msgb_data(msg);
+   xfer->callback = usb_out_xfer_cb;

-   rc = libusb_bulk_transfer(transp->usb_devh, transp->usb_ep.out,
-   msgb_data(msg), msgb_length(msg),
-   &xfer_len, 1000);
+   /* submit the OUT transfer */
+   rc = libusb_submit_transfer(xfer);
+   OSMO_ASSERT(rc == 0);

-   msgb_free(msg);
return rc;
 }

@@ -472,38 +502,106 @@
return rc;
 }

-static void run_mainloop(struct cardem_inst *ci)
+static void usb_in_xfer_cb(struct libusb_transfer *xfer)
 {
-   struct st_transport *transp = ci->slot->transp;
-   unsigned int msg_count, byte_count = 0;
-   uint8_t buf[16*265];
-   int xfer_len;
+   struct cardem_inst *ci = xfer->user_data;
int rc;

-   printf("Entering main loop\n");
-
-   while (1) {
-   /* read data from SIMtrace2 device (local or via USB) */
-   rc = libusb_bulk_transfer(transp->usb_devh, transp->usb_ep.in,
-buf, sizeof(buf), &xfer_len, 100);
-   if (rc < 0 && rc != LIBUSB_ERROR_TIMEOUT &&
-   rc != LIBUSB_ERROR_INTERRUPTED &&
-   rc != LIBUSB_ERROR_IO) {
-   fprintf(stderr, "BULK IN transfer error: %s\n", 
libusb_error_name(rc));
-   return;
-   }
-   /* dispatch any incoming data */
-   if (xfer_len > 0) {
-   process_usb_msg(ci, buf, xfer_len);
-   msg_count++;
-   byte_count += xfer_len;
-   }
-   // handle remote SIM client fsm
-   // TODO register the USB fd for this select
-   osmo_select_main(true);
+   switch (xfer->status) {
+   case LIBUSB_TRANSFER_COMPLETED:
+   /* hand the message up the stack */
+   process_usb_msg(ci, xfer->buffer, xfer->actual_length);
+   break;
+   case LIBUSB_TRANSFER_NO_DEVICE:
+   fprintf(stderr, "USB device disappeared\n");
+   exit(23);
+   break;
+   default:
+   osmo_panic("USB IN transfer failed, status=%u\n", xfer->status);
+   break;
}
+
+   /* re-submit the IN transfer */
+   rc = libusb_submit_transfer(xfer);
+   OSMO_ASSERT(rc == 0);
 }

+
+static void allocate_and_submit_in(struct cardem_inst *ci)
+{
+   struct st_transport *transp = ci->slot->transp;
+   struct libusb_transfer *xfer;
+   int rc;
+
+   xfer = libusb_alloc_transfer(0);
+   OSMO_ASSERT(xfer);
+   xfer->dev_handle = transp->usb_devh;
+   xfer->flags

Change in simtrace2[master]: host_communication: Send zero-length-packet on wMaxPacketSize

2019-12-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16611 )


Change subject: host_communication: Send zero-length-packet on wMaxPacketSize
..

host_communication: Send zero-length-packet on wMaxPacketSize

We need to send zero-length packets on bulk endpoints whenever the
transfer size is exactly a multiple of the wMaxPacketSize.

See USB 2.0 Specification Section 5.8.3 titled "Bulk Transfer Packet
Size constraints."

Change-Id: Ice3842399d5a5c4a18383860f81074497c6e7c9b
Closes: OS#4331
---
M firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
M firmware/atmel_softpack_libraries/usb/include/USBD.h
M firmware/libcommon/source/host_communication.c
3 files changed, 18 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/11/16611/1

diff --git a/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c 
b/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
index 0eccc65..ac2595c 100644
--- a/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
+++ b/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
@@ -1077,6 +1077,14 @@
  *  Exported functions
  *---*/

+
+uint16_t USBD_GetEndpointSize(uint8_t bEndpoint)
+{
+Endpoint *pEndpoint = &(endpoints[bEndpoint]);
+
+return pEndpoint->size;
+}
+
 /**
  * USBD (UDP) interrupt handler
  * Manages device resume, suspend, end of bus reset.
diff --git a/firmware/atmel_softpack_libraries/usb/include/USBD.h 
b/firmware/atmel_softpack_libraries/usb/include/USBD.h
index 15a6859..6fc931f 100644
--- a/firmware/atmel_softpack_libraries/usb/include/USBD.h
+++ b/firmware/atmel_softpack_libraries/usb/include/USBD.h
@@ -214,6 +214,8 @@
  * Exported functions
  
*--*/

+extern uint16_t USBD_GetEndpointSize(uint8_t bEndpoint);
+
 //extern void USBD_IrqHandler(void);

 extern void USBD_Init(void);
diff --git a/firmware/libcommon/source/host_communication.c 
b/firmware/libcommon/source/host_communication.c
index 0e496c5..9a6e5b3 100644
--- a/firmware/libcommon/source/host_communication.c
+++ b/firmware/libcommon/source/host_communication.c
@@ -33,10 +33,18 @@
 {
struct msgb *msg = (struct msgb *) arg;
struct usb_buffered_ep *bep = msg->dst;
+   uint16_t ep_size = USBD_GetEndpointSize(bep->ep);
unsigned long x;

TRACE_DEBUG("%s (EP=0x%02x)\r\n", __func__, bep->ep);

+   if (((msgb_length(msg) % ep_size) == 0) && (transferred == ep_size)) {
+   /* terminate with ZLP; pass in 'msg' again as 'arg' so we get
+* called the second time and proceed with usb_buf_free below */
+   USBD_Write(bep->ep, 0, 0, (TransferCallback) &usb_write_cb, 
msg);
+   return;
+   }
+
local_irq_save(x);
bep->in_progress--;
local_irq_restore(x);

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Ice3842399d5a5c4a18383860f81074497c6e7c9b
Gerrit-Change-Number: 16611
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in simtrace2[master]: host_communication: Send zero-length-packet on wMaxPacketSize

2019-12-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16611 )

Change subject: host_communication: Send zero-length-packet on wMaxPacketSize
..


Patch Set 1: Code-Review+2


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Ice3842399d5a5c4a18383860f81074497c6e7c9b
Gerrit-Change-Number: 16611
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: laforge 
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Sun, 15 Dec 2019 23:10:21 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-remsim[master]: rspro_client_fsm: Fix handling of IPA keepalive

2019-12-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/16591 )

Change subject: rspro_client_fsm: Fix handling of IPA keepalive
..

rspro_client_fsm: Fix handling of IPA keepalive

We cannot rely on the implicit IPA keepalive FSM termination, as that
somehow gets the termination order wrong and we end up accessing free'd
memory.

Let's handle the termination explicitly:  We register a callback with
the IPA keepalive FSM, and once that callback gets hit, we ask the
core to *not* terminate the FSM implicitly.  We are anyway terminating
it explicitly in st_reestablish_onenter().

Change-Id: Ia745ccb44c0d0224d1e7ab6b6da3713474111d41
---
M src/rspro_client_fsm.c
M src/rspro_client_fsm.h
2 files changed, 11 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/rspro_client_fsm.c b/src/rspro_client_fsm.c
index eea8471..758bde7 100644
--- a/src/rspro_client_fsm.c
+++ b/src/rspro_client_fsm.c
@@ -113,6 +113,7 @@
OSMO_VALUE_STRING(SRVC_E_TCP_UP),
OSMO_VALUE_STRING(SRVC_E_TCP_DOWN),
OSMO_VALUE_STRING(SRVC_E_KA_TIMEOUT),
+   OSMO_VALUE_STRING(SRVC_E_KA_TERMINATED),
OSMO_VALUE_STRING(SRVC_E_CLIENT_CONN_RES),
OSMO_VALUE_STRING(SRVC_E_RSPRO_TX),
{ 0, NULL }
@@ -261,6 +262,13 @@
}
 }

+static int ipa_kaepalive_timeout_cb(struct osmo_fsm_inst *ka_fi, void *conn)
+{
+   struct osmo_fsm_inst *fi = ka_fi->proc.parent;
+   osmo_fsm_inst_dispatch(fi, SRVC_E_KA_TIMEOUT, NULL);
+   return 0; /* we will explicitly terminate it */
+}
+
 static void srvc_st_reestablish_onenter(struct osmo_fsm_inst *fi, uint32_t 
prev_state)
 {
struct rspro_server_conn *srvc = (struct rspro_server_conn *) fi->priv;
@@ -292,8 +300,9 @@
LOGPFSM(fi, "Unable to create keepalive FSM\n");
exit(1);
}
+   ipa_keepalive_fsm_set_timeout_cb(srvc->keepalive_fi, 
ipa_kaepalive_timeout_cb);
/* ensure parent is notified once keepalive FSM instance is dying */
-   osmo_fsm_inst_change_parent(srvc->keepalive_fi, srvc->fi, 
SRVC_E_KA_TIMEOUT);
+   osmo_fsm_inst_change_parent(srvc->keepalive_fi, srvc->fi, 
SRVC_E_KA_TERMINATED);

/* Attempt to connect TCP socket */
rc = ipa_client_conn_open(srvc->conn);
diff --git a/src/rspro_client_fsm.h b/src/rspro_client_fsm.h
index b1c14f8..ca59c77 100644
--- a/src/rspro_client_fsm.h
+++ b/src/rspro_client_fsm.h
@@ -9,6 +9,7 @@
SRVC_E_TCP_UP,
SRVC_E_TCP_DOWN,
SRVC_E_KA_TIMEOUT,
+   SRVC_E_KA_TERMINATED,
SRVC_E_CLIENT_CONN_RES,
SRVC_E_RSPRO_TX /* transmit a RSPRO PDU to the peer */
 };

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

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: Ia745ccb44c0d0224d1e7ab6b6da3713474111d41
Gerrit-Change-Number: 16591
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in osmo-remsim[master]: rspro_client_fsm: Fix handling of IPA keepalive

2019-12-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/16591 )

Change subject: rspro_client_fsm: Fix handling of IPA keepalive
..


Patch Set 3: Code-Review+2


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

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: Ia745ccb44c0d0224d1e7ab6b6da3713474111d41
Gerrit-Change-Number: 16591
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sun, 15 Dec 2019 23:11:05 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in simtrace2[master]: card_emu: Avoid recursive calls to card_set_state()

2019-12-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16602 )

Change subject: card_emu: Avoid recursive calls to card_set_state()
..


Patch Set 4: Code-Review+2


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Ieefa1807099eb234cfd994bca83caaa0dcc919b6
Gerrit-Change-Number: 16602
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sun, 15 Dec 2019 23:10:35 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-remsim[master]: rspro_client_fsm: Fix uninitialized return variable use

2019-12-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/16596 )

Change subject: rspro_client_fsm: Fix uninitialized return variable use
..

rspro_client_fsm: Fix uninitialized return variable use

rspro_client_fsm.c:180:9: warning: ‘rc’ may be used uninitialized in this 
function [-Wmaybe-uninitialized]
  180 |  return rc;
  | ^~

Change-Id: I64b275b06b2aa40bd7c6e1dd42afba5ffebd7b00
---
M src/rspro_client_fsm.c
1 file changed, 3 insertions(+), 1 deletion(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/rspro_client_fsm.c b/src/rspro_client_fsm.c
index 6be2fef..eea8471 100644
--- a/src/rspro_client_fsm.c
+++ b/src/rspro_client_fsm.c
@@ -162,8 +162,10 @@
case IPAC_PROTO_EXT_RSPRO:
LOGPFSM(srvc->fi, "Received RSPRO %s\n", 
msgb_hexdump(msg));
pdu = rspro_dec_msg(msg);
-   if (!pdu)
+   if (!pdu) {
+   rc = -EIO;
break;
+   }
rc = srvc->handle_rx(srvc, pdu);
ASN_STRUCT_FREE(asn_DEF_RsproPDU, pdu);
break;

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

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I64b275b06b2aa40bd7c6e1dd42afba5ffebd7b00
Gerrit-Change-Number: 16596
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in simtrace2[master]: host_communication: Send zero-length-packet on wMaxPacketSize

2019-12-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16611 )

Change subject: host_communication: Send zero-length-packet on wMaxPacketSize
..

host_communication: Send zero-length-packet on wMaxPacketSize

We need to send zero-length packets on bulk endpoints whenever the
transfer size is exactly a multiple of the wMaxPacketSize.

See USB 2.0 Specification Section 5.8.3 titled "Bulk Transfer Packet
Size constraints."

Change-Id: Ice3842399d5a5c4a18383860f81074497c6e7c9b
Closes: OS#4331
---
M firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
M firmware/atmel_softpack_libraries/usb/include/USBD.h
M firmware/libcommon/source/host_communication.c
3 files changed, 18 insertions(+), 0 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c 
b/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
index 0eccc65..ac2595c 100644
--- a/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
+++ b/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
@@ -1077,6 +1077,14 @@
  *  Exported functions
  *---*/

+
+uint16_t USBD_GetEndpointSize(uint8_t bEndpoint)
+{
+Endpoint *pEndpoint = &(endpoints[bEndpoint]);
+
+return pEndpoint->size;
+}
+
 /**
  * USBD (UDP) interrupt handler
  * Manages device resume, suspend, end of bus reset.
diff --git a/firmware/atmel_softpack_libraries/usb/include/USBD.h 
b/firmware/atmel_softpack_libraries/usb/include/USBD.h
index 15a6859..6fc931f 100644
--- a/firmware/atmel_softpack_libraries/usb/include/USBD.h
+++ b/firmware/atmel_softpack_libraries/usb/include/USBD.h
@@ -214,6 +214,8 @@
  * Exported functions
  
*--*/

+extern uint16_t USBD_GetEndpointSize(uint8_t bEndpoint);
+
 //extern void USBD_IrqHandler(void);

 extern void USBD_Init(void);
diff --git a/firmware/libcommon/source/host_communication.c 
b/firmware/libcommon/source/host_communication.c
index 0e496c5..9a6e5b3 100644
--- a/firmware/libcommon/source/host_communication.c
+++ b/firmware/libcommon/source/host_communication.c
@@ -33,10 +33,18 @@
 {
struct msgb *msg = (struct msgb *) arg;
struct usb_buffered_ep *bep = msg->dst;
+   uint16_t ep_size = USBD_GetEndpointSize(bep->ep);
unsigned long x;

TRACE_DEBUG("%s (EP=0x%02x)\r\n", __func__, bep->ep);

+   if (((msgb_length(msg) % ep_size) == 0) && (transferred == ep_size)) {
+   /* terminate with ZLP; pass in 'msg' again as 'arg' so we get
+* called the second time and proceed with usb_buf_free below */
+   USBD_Write(bep->ep, 0, 0, (TransferCallback) &usb_write_cb, 
msg);
+   return;
+   }
+
local_irq_save(x);
bep->in_progress--;
local_irq_restore(x);

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Ice3842399d5a5c4a18383860f81074497c6e7c9b
Gerrit-Change-Number: 16611
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in simtrace2[master]: card_emu: Initialize PTSS state every time we start PTS

2019-12-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/16601 )

Change subject: card_emu: Initialize PTSS state every time we start PTS
..

card_emu: Initialize PTSS state every time we start PTS

Let's shift the responsibility from the caller side to the calee side.

Change-Id: I39661ca93c87b2e2071765f69578eec5aaf90ce4
---
M firmware/libcommon/source/card_emu.c
1 file changed, 2 insertions(+), 4 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/firmware/libcommon/source/card_emu.c 
b/firmware/libcommon/source/card_emu.c
index 63bf0d3..c3299de 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -240,7 +240,6 @@
 
tc_etu_disable(ch->tc_chan);

-   ch->pts.state = PTS_S_WAIT_REQ_PTSS;
ch->tpdu.state = TPDU_S_WAIT_CLA;

/* release any buffers we may still own */
@@ -534,8 +533,6 @@
/* update waiting time (see ISO 7816-3 10.2) */
ch->waiting_time = ch->wi * 960 * ch->fi;
tc_etu_set_wtime(ch->tc_chan, ch->waiting_time);
-   /* reset PTS to initial state */
-   set_pts_state(ch, PTS_S_WAIT_REQ_PTSS);
/* go to next state */
card_set_state(ch, ISO_S_WAIT_TPDU);
return 0;
@@ -701,7 +698,6 @@
emu_update_fidi(ch);
/* Wait for the next TPDU */
card_set_state(ch, ISO_S_WAIT_TPDU);
-   set_pts_state(ch, PTS_S_WAIT_REQ_PTSS);
break;
default:
/* calculate the next state and set it */
@@ -979,6 +975,8 @@
switch (ch->state) {
case ISO_S_WAIT_TPDU:
if (byte == 0xff) {
+   /* reset PTS to initial state */
+   set_pts_state(ch, PTS_S_WAIT_REQ_PTSS);
new_state = process_byte_pts(ch, byte);
ch->stats.pps++;
goto out_silent;

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I39661ca93c87b2e2071765f69578eec5aaf90ce4
Gerrit-Change-Number: 16601
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in libosmocore[master]: gprs_bssgp: Work around gcc-9 claiming "error=stringop-overflow"

2019-12-15 Thread fixeria
fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/16608 )

Change subject: gprs_bssgp: Work around gcc-9 claiming "error=stringop-overflow"
..


Patch Set 1: Code-Review+1


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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I22a0c399c6c00eaf87277002096a82844c9e198e
Gerrit-Change-Number: 16608
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Comment-Date: Sun, 15 Dec 2019 23:14:23 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Build failure of network:osmocom:nightly/simtrace2 in xUbuntu_16.04/i586

2019-12-15 Thread OBS Notification
Visit 
https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/simtrace2/xUbuntu_16.04/i586

Package network:osmocom:nightly/simtrace2 failed to build in xUbuntu_16.04/i586

Check out the package for editing:
  osc checkout network:osmocom:nightly simtrace2

Last lines of build log:
[   83s] /usr/src/packages/BUILD/firmware/apps/dfu/main.c:360: warning: 
undefined reference to `__stack_chk_guard'
[   83s] obj/simtrace/flash_dfu_desc.o: In function `set_usb_serial_str':
[   83s] 
/usr/src/packages/BUILD/firmware/./atmel_softpack_libraries/usb/device/dfu/dfu_desc.c:186:
 warning: undefined reference to `__stack_chk_fail'
[   83s] 
/usr/src/packages/BUILD/firmware/./atmel_softpack_libraries/usb/device/dfu/dfu_desc.c:186:
 warning: undefined reference to `__stack_chk_guard'
[   83s] obj/simtrace/flash_dfu_driver.o: In function `handle_getstate':
[   83s] 
/usr/src/packages/BUILD/firmware/./atmel_softpack_libraries/usb/device/dfu/dfu_driver.c:91:
 warning: undefined reference to `__stack_chk_fail'
[   83s] 
/usr/src/packages/BUILD/firmware/./atmel_softpack_libraries/usb/device/dfu/dfu_driver.c:91:
 warning: undefined reference to `__stack_chk_guard'
[   83s] collect2: error: ld returned 1 exit status
[   83s] %
[   83s] Makefile:233: recipe for target 'flash' failed
[   83s] make[2]: *** [flash] Error 1
[   83s] make[2]: Leaving directory '/usr/src/packages/BUILD/firmware'
[   83s] Makefile:10: recipe for target 'fw-simtrace-dfu' failed
[   83s] make[1]: *** [fw-simtrace-dfu] Error 2
[   83s] make[1]: Leaving directory '/usr/src/packages/BUILD'
[   83s] dh_auto_build: make -j1 returned exit code 2
[   83s] debian/rules:16: recipe for target 'build' failed
[   83s] make: *** [build] Error 2
[   83s] dpkg-buildpackage: error: debian/rules build gave error exit status 2
[   83s] 
[   83s] lamb61 failed "build simtrace2_0.7.0.24.02d0d.dsc" at Mon Dec 16 
01:39:30 UTC 2019.
[   83s] 
[   83s] ### VM INTERACTION START ###
[   87s] [   75.986130] sysrq: SysRq : Power Off
[   87s] [   75.992334] reboot: Power down
[   87s] ### VM INTERACTION END ###
[   87s] 
[   87s] lamb61 failed "build simtrace2_0.7.0.24.02d0d.dsc" at Mon Dec 16 
01:39:34 UTC 2019.
[   87s] 

-- 
Configure notifications at https://build.opensuse.org/my/notifications
openSUSE Build Service (https://build.opensuse.org/)


Build failure of network:osmocom:nightly/simtrace2 in xUbuntu_16.04/x86_64

2019-12-15 Thread OBS Notification
Visit 
https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/simtrace2/xUbuntu_16.04/x86_64

Package network:osmocom:nightly/simtrace2 failed to build in 
xUbuntu_16.04/x86_64

Check out the package for editing:
  osc checkout network:osmocom:nightly simtrace2

Last lines of build log:
[   91s] /usr/src/packages/BUILD/firmware/apps/dfu/main.c:360: warning: 
undefined reference to `__stack_chk_guard'
[   91s] obj/simtrace/flash_dfu_desc.o: In function `set_usb_serial_str':
[   91s] 
/usr/src/packages/BUILD/firmware/./atmel_softpack_libraries/usb/device/dfu/dfu_desc.c:186:
 warning: undefined reference to `__stack_chk_fail'
[   91s] 
/usr/src/packages/BUILD/firmware/./atmel_softpack_libraries/usb/device/dfu/dfu_desc.c:186:
 warning: undefined reference to `__stack_chk_guard'
[   91s] obj/simtrace/flash_dfu_driver.o: In function `handle_getstate':
[   91s] 
/usr/src/packages/BUILD/firmware/./atmel_softpack_libraries/usb/device/dfu/dfu_driver.c:91:
 warning: undefined reference to `__stack_chk_fail'
[   91s] 
/usr/src/packages/BUILD/firmware/./atmel_softpack_libraries/usb/device/dfu/dfu_driver.c:91:
 warning: undefined reference to `__stack_chk_guard'
[   91s] collect2: error: ld returned 1 exit status
[   91s] %
[   91s] Makefile:233: recipe for target 'flash' failed
[   91s] make[2]: *** [flash] Error 1
[   91s] make[2]: Leaving directory '/usr/src/packages/BUILD/firmware'
[   91s] Makefile:10: recipe for target 'fw-simtrace-dfu' failed
[   91s] make[1]: *** [fw-simtrace-dfu] Error 2
[   91s] make[1]: Leaving directory '/usr/src/packages/BUILD'
[   91s] dh_auto_build: make -j1 returned exit code 2
[   91s] debian/rules:16: recipe for target 'build' failed
[   91s] make: *** [build] Error 2
[   91s] dpkg-buildpackage: error: debian/rules build gave error exit status 2
[   91s] 
[   91s] cloud101 failed "build simtrace2_0.7.0.24.02d0d.dsc" at Mon Dec 16 
01:39:38 UTC 2019.
[   91s] 
[   91s] ### VM INTERACTION START ###
[   95s] [   81.620708] sysrq: SysRq : Power Off
[   95s] [   81.625750] reboot: Power down
[   95s] ### VM INTERACTION END ###
[   95s] 
[   95s] cloud101 failed "build simtrace2_0.7.0.24.02d0d.dsc" at Mon Dec 16 
01:39:42 UTC 2019.
[   95s] 

-- 
Configure notifications at https://build.opensuse.org/my/notifications
openSUSE Build Service (https://build.opensuse.org/)


Build failure of network:osmocom:latest/libosmo-netif in Debian_Testing/x86_64

2019-12-15 Thread OBS Notification
Visit 
https://build.opensuse.org/package/live_build_log/network:osmocom:latest/libosmo-netif/Debian_Testing/x86_64

Package network:osmocom:latest/libosmo-netif failed to build in 
Debian_Testing/x86_64

Check out the package for editing:
  osc checkout network:osmocom:latest libosmo-netif

Last lines of build log:
[  165s]  
[  165s] -non-reconnecting test step 0 [client OK, server OK], FD reg 0
[  165s] +non-reconnecting test step 0 [client OK, server OK], FD reg 1
[  165s] --- expout 2019-12-16 04:03:16.66800 +
[  165s] +++ /usr/src/packages/BUILD/tests/testsuite.dir/at-groups/1/stdout 
2019-12-16 04:03:25.68800 +
[  165s] @@ -44,8 +44,6 @@
[  165s]  [OK|OK] Server's read_cb_srv(): received 29(29) bytes: 44 6f 68 2c 20 
72 65 73 70 6f 6e 64 69 6e 67 20 74 6f 20 73 65 72 76 65 72 20 3a 2d 44 
[  165s]  [OK|OK] Server's read_cb_srv(): sent 11 bytes message: 72 65 61 64 5f 
63 62 5f 73 72 76 
[  165s]  [OK|OK] Server's read_cb_srv(): force client disconnect on subsequent 
call
[  165s] -[OK] Client's read_cb_cli(): callback triggered
[  165s] -[OK] Client's read_cb_cli(): 0-byte read, auto-reconnect will be 
triggered if enabled
[  165s]  non-reconnecting test complete.
[  165s]  
[  165s]  Stream tests completed
[  165s] 1. testsuite.at:4: 1. stream_test (testsuite.at:4): FAILED 
(testsuite.at:8)
[  165s] make[1]: *** [debian/rules:27: override_dh_auto_test] Error 1
[  165s] make[1]: Leaving directory '/usr/src/packages/BUILD'
[  165s] make: *** [debian/rules:13: build] Error 2
[  165s] dpkg-buildpackage: error: debian/rules build subprocess returned exit 
status 2
[  165s] 
[  165s] lamb11 failed "build libosmo-netif_0.6.0.dsc" at Mon Dec 16 04:03:26 
UTC 2019.
[  165s] 
[  165s] ### VM INTERACTION START ###
[  167s] [  153.313375] sysrq: SysRq : Power Off
[  167s] [  153.322212] reboot: Power down
[  168s] ### VM INTERACTION END ###
[  168s] 
[  168s] lamb11 failed "build libosmo-netif_0.6.0.dsc" at Mon Dec 16 04:03:30 
UTC 2019.
[  168s] 

-- 
Configure notifications at https://build.opensuse.org/my/notifications
openSUSE Build Service (https://build.opensuse.org/)