Skip to contentSkip to conversation

tty: n_gsm: Fix CR bit value when initiator=0

PATCH Superseded Zhenguo Zhao 3 participants 6 messages Jun 16, 2021 TTY layer and serial drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: n_gsm: Fix CR bit value when initiator=0

From: Zhenguo Zhao <[email protected]>

	When set initiator=0,switch to Responder,gsmld received dlci SABM/DISC
	frame,CR bit should be 0 by calculation.

	receive DLC0 SABM CMD:
	[69.740263] c1 gsmld_receive: 00000000: f9 03 3f 01 1c f9
	[69.893247] c1 gsm_queue cr:1
	[69.897629] c1 <-- 0) C: SABM(P)
	[69.907516] c1 gsm_queue cr:0
---
 drivers/tty/n_gsm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/n_gsm.c +2 -2
index 5fea02c..becca2c 100644
@@ -1779,7 +1779,7 @@ static void gsm_queue(struct gsm_mux *gsm)
 
 	switch (gsm->control) {
 	case SABM|PF:
-		if (cr == 0)
+		if (cr == 1)
 			goto invalid;
 		if (dlci == NULL)
 			dlci = gsm_dlci_alloc(gsm, address);
@@ -1793,7 +1793,7 @@ static void gsm_queue(struct gsm_mux *gsm)
 		}
 		break;
 	case DISC|PF:
-		if (cr == 0)
+		if (cr == 1)
 			goto invalid;
 		if (dlci == NULL || dlci->state == DLCI_CLOSED) {
 			gsm_response(gsm, address, DM);
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 10 lines · Zhenguo Zhao

From: Zhenguo Zhao <[email protected]>

	When set initiator=0,switch to Responder,gsmld received dlci SABM/DISC
	frame,CR bit should be 0 by calculation.

	receive DLC0 SABM CMD:
	[69.740263] c1 gsmld_receive: 00000000: f9 03 3f 01 1c f9
	[69.893247] c1 gsm_queue cr:1
	[69.897629] c1 <-- 0) C: SABM(P)
	[69.907516] c1 gsm_queue cr:0

Why is this changelog text indented by tabs?

And I do not understand the changelog text here, what is this showing? What is wrong here and what is being fixed?

Quoted 1 line

Does this fix a long-standing issue? Should a "Fixes:" tag go here? If so, please provide it.

Should it also be sent to stable kernels?

Quoted 9 lines
---
 drivers/tty/n_gsm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/n_gsm.c +0 -0
index 5fea02c..becca2c 100644

drivers/tty/n_gsm.c static void gsm_queue(struct gsm_mux *gsm) · line 1782

Quoted 5 lines
drivers/tty/n_gsm.c +1 -1
@@ -1779,7 +1779,7 @@ static void gsm_queue(struct gsm_mux *gsm)
 
 	switch (gsm->control) {
 	case SABM|PF:
-		if (cr == 0)
+		if (cr == 1)

How did the original code ever work properly?

drivers/tty/n_gsm.c static void gsm_queue(struct gsm_mux *gsm) · line 1796

Quoted 9 lines
drivers/tty/n_gsm.c +1 -1
 			goto invalid;
 		if (dlci == NULL)
 			dlci = gsm_dlci_alloc(gsm, address);
@@ -1793,7 +1793,7 @@ static void gsm_queue(struct gsm_mux *gsm)
 		}
 		break;
 	case DISC|PF:
-		if (cr == 0)
+		if (cr == 1)

Same here, how did this ever work? Are you sure this change is correct?

thanks,

greg k-h

author
#2 lore raw

Dear gregkh

1: Documentation/driver-api/serial/n_gsm.rst

The text introduces the config of master ( c.initiator = 1), but the config of as responder is different.
when set gsm->initiator=0 by GSMIOC_SETCONF ,ngsm driver should be responder(slaver)

config:

	c.initiator = 0;    // set initiator=0,ngsm as responder
	ioctl(fd, GSMIOC_SETCONF, &c);

2: if master side send SABM/DISC frame data by uart dev
DLC0 control data frame:f9 03 3f 01 1c f9 kernel log: gsmld_receive: 00000000: f9 03 3f 01 1c f9

{
	cr = gsm->address & 1;		/* C/R bit */

//CR value=1

	gsm_print_packet("<--", address, cr, gsm->control, gsm->buf, gsm->len);

	cr ^= 1 - gsm->initiator;	/* Flip so 1 always means command */
//when gsm->initiator is 0, CR value=0 by "^=" calculation
	dlci = gsm->dlci[address];

	switch (gsm->control) {
	case SABM|PF:
		if (cr == 0)
			goto invalid;                       //if CR value=0,ngsm will goto

invalid,but the dlc0 control frame data is right,if we can't modify ,ngsm can't send UA response data
}

2021-06-16 14:19 GMT+08:00, Greg KH <[email protected]>:

Quoted 57 lines · Zhenguo Zhao
Quoted 10 lines

From: Zhenguo Zhao <[email protected]>

	When set initiator=0,switch to Responder,gsmld received dlci SABM/DISC
	frame,CR bit should be 0 by calculation.

	receive DLC0 SABM CMD:
	[69.740263] c1 gsmld_receive: 00000000: f9 03 3f 01 1c f9
	[69.893247] c1 gsm_queue cr:1
	[69.897629] c1 <-- 0) C: SABM(P)
	[69.907516] c1 gsm_queue cr:0

Why is this changelog text indented by tabs?

And I do not understand the changelog text here, what is this showing? What is wrong here and what is being fixed?

Quoted 1 line

Does this fix a long-standing issue? Should a "Fixes:" tag go here? If so, please provide it.

Should it also be sent to stable kernels?

Quoted 9 lines
---
 drivers/tty/n_gsm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/n_gsm.c +0 -0
index 5fea02c..becca2c 100644

drivers/tty/n_gsm.c static void gsm_queue(struct gsm_mux *gsm) · line 1782

Quoted 5 lines
drivers/tty/n_gsm.c +1 -1
@@ -1779,7 +1779,7 @@ static void gsm_queue(struct gsm_mux *gsm)
 
 	switch (gsm->control) {
 	case SABM|PF:
-		if (cr == 0)
+		if (cr == 1)

How did the original code ever work properly?

drivers/tty/n_gsm.c static void gsm_queue(struct gsm_mux *gsm) · line 1796

Quoted 9 lines
drivers/tty/n_gsm.c +1 -1
 			goto invalid;
 		if (dlci == NULL)
 			dlci = gsm_dlci_alloc(gsm, address);
@@ -1793,7 +1793,7 @@ static void gsm_queue(struct gsm_mux *gsm)
 		}
 		break;
 	case DISC|PF:
-		if (cr == 0)
+		if (cr == 1)

Same here, how did this ever work? Are you sure this change is correct?

thanks,

greg k-h

maintainer
#3 lore raw

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

Quoted 31 lines · 赵振国

Dear gregkh

1: Documentation/driver-api/serial/n_gsm.rst

The text introduces the config of master ( c.initiator = 1), but the config of as responder is different.
when set gsm->initiator=0 by GSMIOC_SETCONF ,ngsm driver should be responder(slaver)

config:

	c.initiator = 0;    // set initiator=0,ngsm as responder
	ioctl(fd, GSMIOC_SETCONF, &c);

2: if master side send SABM/DISC frame data by uart dev
DLC0 control data frame:f9 03 3f 01 1c f9 kernel log: gsmld_receive: 00000000: f9 03 3f 01 1c f9

{
	cr = gsm->address & 1;		/* C/R bit */

//CR value=1

	gsm_print_packet("<--", address, cr, gsm->control, gsm->buf, gsm->len);

	cr ^= 1 - gsm->initiator;	/* Flip so 1 always means command */
//when gsm->initiator is 0, CR value=0 by "^=" calculation
	dlci = gsm->dlci[address];

	switch (gsm->control) {
	case SABM|PF:
		if (cr == 0)
			goto invalid;                       //if CR value=0,ngsm will goto
Quoted 3 lines

invalid,but the dlc0 control frame data is right,if we can't modify ,ngsm can't send UA response data
}

I am sorry, but I really do not understand what you are saying here. Please resubmit your patch with an updated changelog that explains why this change is needed and what it does.

thanks,

greg k-h

maintainer
#4 lore raw
Quoted 49 lines · Greg KH

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

Quoted 31 lines · 赵振国

Dear gregkh

1: Documentation/driver-api/serial/n_gsm.rst

The text introduces the config of master ( c.initiator = 1), but the config of as responder is different.
when set gsm->initiator=0 by GSMIOC_SETCONF ,ngsm driver should be responder(slaver)

config:

	c.initiator = 0;    // set initiator=0,ngsm as responder
	ioctl(fd, GSMIOC_SETCONF, &c);

2: if master side send SABM/DISC frame data by uart dev
DLC0 control data frame:f9 03 3f 01 1c f9 kernel log: gsmld_receive: 00000000: f9 03 3f 01 1c f9

{
	cr = gsm->address & 1;		/* C/R bit */

//CR value=1

	gsm_print_packet("<--", address, cr, gsm->control, gsm->buf, gsm->len);

	cr ^= 1 - gsm->initiator;	/* Flip so 1 always means command */
//when gsm->initiator is 0, CR value=0 by "^=" calculation
	dlci = gsm->dlci[address];

	switch (gsm->control) {
	case SABM|PF:
		if (cr == 0)
			goto invalid;                       //if CR value=0,ngsm will goto
Quoted 3 lines

invalid,but the dlc0 control frame data is right,if we can't modify ,ngsm can't send UA response data
}

Quoted 3 lines

I am sorry, but I really do not understand what you are saying here. Please resubmit your patch with an updated changelog that explains why this change is needed and what it does.

And why it was able to work until now. I.e. isn't the Documentation wrong?

thanks,

Signature · 2 lines
js
suse labs
author
#5 lore raw

Dear gregkh,Jiri

I think that linux ngsm is cp cmux function (config slaver,c.initiator = 0),pc side or ubuntu or terminal will send "AT+CMUX" by tty dev, and send SABM.DISC.CLD command。

because project is YOCTO,YOCTO is IOT open project,need config slaver,after config “c.initiator = 0”,ngsm can‘t work normally.

slaver config ,it doesn't need to send "AT+CMUX"
----------------------------------------------------------
2.1 switch the serial line to using the n_gsm line discipline by using
TIOCSETD ioctl.
2.2 configure the mux using GSMIOC_GETCONF / GSMIOC_SETCONF ioctl. 2.3 obtain base gsmtty number for the used serial port,

  #include <stdio.h>
  #include <stdint.h>
  #include <linux/gsmmux.h>
  #include <linux/tty.h>
  #define DEFAULT_SPEED B115200
  #define SERIAL_PORT   /dev/ttyS0
    int ldisc = N_GSM0710;
    struct gsm_config c;
    struct termios configuration;
    uint32_t first;

    /* open the serial port */
    fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY);

    /* configure the serial port : speed, flow control ... */

    /* use n_gsm line discipline */
    ioctl(fd, TIOCSETD, &ldisc);

    /* get n_gsm configuration */
    ioctl(fd, GSMIOC_GETCONF, &c);
    /* we are responter and need encoding 0 (basic) */
    c.initiator = 0;
    c.encapsulation = 0;
    /* our modem defaults to a maximum size of 127 bytes */
    c.mru = 127;
    c.mtu = 127;
    /* set the new configuration */
    ioctl(fd, GSMIOC_SETCONF, &c);
    /* get first gsmtty device node */
    ioctl(fd, GSMIOC_GETFIRST, &first);
    printf("first muxed line: /dev/gsmtty%i\n", first);

    /* and wait for ever to keep the line discipline enabled */
    daemon(0,0);
    pause();

2021-06-16 15:45 GMT+08:00, Jiri Slaby <[email protected]>:

Quoted 61 lines · Greg KH
Quoted 49 lines

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

Quoted 31 lines · 赵振国

Dear gregkh

1: Documentation/driver-api/serial/n_gsm.rst

The text introduces the config of master ( c.initiator = 1), but the config of as responder is different.
when set gsm->initiator=0 by GSMIOC_SETCONF ,ngsm driver should be responder(slaver)

config:

	c.initiator = 0;    // set initiator=0,ngsm as responder
	ioctl(fd, GSMIOC_SETCONF, &c);

2: if master side send SABM/DISC frame data by uart dev
DLC0 control data frame:f9 03 3f 01 1c f9 kernel log: gsmld_receive: 00000000: f9 03 3f 01 1c f9

{
	cr = gsm->address & 1;		/* C/R bit */

//CR value=1

	gsm_print_packet("<--", address, cr, gsm->control, gsm->buf, gsm->len);

	cr ^= 1 - gsm->initiator;	/* Flip so 1 always means command */
//when gsm->initiator is 0, CR value=0 by "^=" calculation
	dlci = gsm->dlci[address];

	switch (gsm->control) {
	case SABM|PF:
		if (cr == 0)
			goto invalid;                       //if CR value=0,ngsm will goto
Quoted 3 lines

invalid,but the dlc0 control frame data is right,if we can't modify ,ngsm can't send UA response data
}

Quoted 3 lines

I am sorry, but I really do not understand what you are saying here. Please resubmit your patch with an updated changelog that explains why this change is needed and what it does.

And why it was able to work until now. I.e. isn't the Documentation wrong?

thanks,
--
js
suse labs