tty: n_gsm: Modify CR,PF bit when config requester

When n_gsm config "initiator=0",as requester,gsmld receives dlci SABM/DISC
control command frame,but send UA frame is error.

Example:
Gsmld receive dlc0 SABM frame "f9 03 3f 01 1c f9",now it sends UA
frame "f9 01 63 01 a3 f9",CR and PF bit are 0,but it should be set
1 from requster to initiator.

Kernel test log as follows:

Before modify

[  271.732031] c1 gsmld_receive: 00000000: f9 03 3f 01 1c f9
[  271.741719] c1 <-- 0) C: SABM(P)
[  271.749483] c1 gsmld_output: 00000000: f9 01 63 01 a3 f9
[  271.758337] c1 --> 0) R: UA(F)

After modify

[  261.233188] c0 gsmld_receive: 00000000: f9 03 3f 01 1c f9
[  261.242767] c0 <-- 0) C: SABM(P)
[  261.250497] c0 gsmld_output: 00000000: f9 03 73 01 d7 f9
[  261.259759] c0 --> 0) C: UA(P)

Signed-off-by: Zhenguo Zhao <Zhenguo.Zhao1@unisoc.com>
Link: https://lore.kernel.org/r/1629461872-26965-3-git-send-email-zhenguo6858@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Zhenguo Zhao 2021-08-20 20:17:47 +08:00 committed by Greg Kroah-Hartman
parent cd93662137
commit cc0f42122a

View File

@ -601,7 +601,7 @@ static void gsm_send(struct gsm_mux *gsm, int addr, int cr, int control)
static inline void gsm_response(struct gsm_mux *gsm, int addr, int control) static inline void gsm_response(struct gsm_mux *gsm, int addr, int control)
{ {
gsm_send(gsm, addr, 0, control); gsm_send(gsm, addr, 1, control);
} }
/** /**
@ -1786,9 +1786,9 @@ static void gsm_queue(struct gsm_mux *gsm)
if (dlci == NULL) if (dlci == NULL)
return; return;
if (dlci->dead) if (dlci->dead)
gsm_response(gsm, address, DM); gsm_response(gsm, address, DM|PF);
else { else {
gsm_response(gsm, address, UA); gsm_response(gsm, address, UA|PF);
gsm_dlci_open(dlci); gsm_dlci_open(dlci);
} }
break; break;
@ -1796,11 +1796,11 @@ static void gsm_queue(struct gsm_mux *gsm)
if (cr == 1) if (cr == 1)
goto invalid; goto invalid;
if (dlci == NULL || dlci->state == DLCI_CLOSED) { if (dlci == NULL || dlci->state == DLCI_CLOSED) {
gsm_response(gsm, address, DM); gsm_response(gsm, address, DM|PF);
return; return;
} }
/* Real close complete */ /* Real close complete */
gsm_response(gsm, address, UA); gsm_response(gsm, address, UA|PF);
gsm_dlci_close(dlci); gsm_dlci_close(dlci);
break; break;
case UA: case UA: