All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] tty: n_gsm: CR bit value should be 0 when config "initiator=0"
@ 2021-06-16 11:53 Zhenguo Zhao
  2021-06-24 12:58 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Zhenguo Zhao @ 2021-06-16 11:53 UTC (permalink / raw)
  To: zhenguo6858, gregkh, jirislaby; +Cc: linux-kernel

From: Zhenguo Zhao <zhenguo.zhao1@unisoc.com>

config "initiator=0",gsmld will receives dlci SABM/DISC control command
frame,as slaver,the CR bit value check should be 1.

if check "cr == 0",it will goto invalid,so it can't send UA response
frame and open slaver dlci.

Signed-off-by: Zhenguo Zhao <zhenguo.zhao1@unisoc.com>
---
 drivers/tty/n_gsm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 5fea02c..becca2c 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -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);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] tty: n_gsm: CR bit value should be 0 when config "initiator=0"
  2021-06-16 11:53 [PATCH v2] tty: n_gsm: CR bit value should be 0 when config "initiator=0" Zhenguo Zhao
@ 2021-06-24 12:58 ` Greg KH
       [not found] ` <CAGGV+3LgLdohhYhH+qJTokeNU_WdV9oRNHMc9a_5YTTVA3U8ow@mail.gmail.com>
  2021-07-07  6:12 ` 赵振国
  2 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2021-06-24 12:58 UTC (permalink / raw)
  To: Zhenguo Zhao; +Cc: jirislaby, linux-kernel

On Wed, Jun 16, 2021 at 07:53:22PM +0800, Zhenguo Zhao wrote:
> From: Zhenguo Zhao <zhenguo.zhao1@unisoc.com>
> 
> config "initiator=0",gsmld will receives dlci SABM/DISC control command
> frame,as slaver,the CR bit value check should be 1.

I am really sorry, but I do not understand this changelog comment.  Can
you try rewriting it again?

> 
> if check "cr == 0",it will goto invalid,so it can't send UA response
> frame and open slaver dlci.

Same here, I do not understand.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] tty: n_gsm: CR bit value should be 0 when config "initiator=0"
       [not found] ` <CAGGV+3LgLdohhYhH+qJTokeNU_WdV9oRNHMc9a_5YTTVA3U8ow@mail.gmail.com>
@ 2021-07-07  6:08   ` 赵振国
  2021-07-07  6:10   ` Greg KH
  1 sibling, 0 replies; 6+ messages in thread
From: 赵振国 @ 2021-07-07  6:08 UTC (permalink / raw)
  To: 赵振国; +Cc: linux-kernel

Dear Jiri,Greg

 1:   our development board uses linux kernel , uart dev node is "/dev/ttyGS2"
 2:   config uart "/dev/ttyGS2" ,we use ngsm ldisc,and config
"c.initiator = 0;" code is as follows

  #include <stdio.h>
  #include <stdint.h>
  #include <linux/gsmmux.h>
  #include <linux/tty.h>
  #define DEFAULT_SPEED      B115200
  #define SERIAL_PORT        /dev/ttyGS2

     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();

3:  connect to ubuntu by uart serial port cable,ubuntu uart dev node
is /"dev/ttyUSB0"
send  DLC0 SABM command by "/dev/ttyUSB0",but linux development board
can't response,code is as follows

int main(int argc, char **argv)
{
    int fd;
fd = open("/dev/ttyUSB0,O_RDWR | O_NOCTTY | O_NDELAY);
char buf[256]={0xf9,0x03,0x3f,0x01,0x1c,0xf9};
write(fd,buf,6);
close(fd);
}

4:  linux development board receive data,by uart,gsm_queue will check
CR,find CR=1.so go to invalid,pls check again.
static void gsm_queue(struct gsm_mux *gsm)
{
cr ^= 1 - gsm->initiator; /* Flip so 1 always means command */
dlci = gsm->dlci[address];

switch (gsm->control) {
case SABM|PF:
if (cr == 0)
goto invalid;
if (dlci == NULL)
dlci = gsm_dlci_alloc(gsm, address);
if (dlci == NULL)
return;
if (dlci->dead)
gsm_response(gsm, address, DM);
else {
gsm_response(gsm, address, UA);
gsm_dlci_open(dlci);
}
break;

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] tty: n_gsm: CR bit value should be 0 when config "initiator=0"
       [not found] ` <CAGGV+3LgLdohhYhH+qJTokeNU_WdV9oRNHMc9a_5YTTVA3U8ow@mail.gmail.com>
  2021-07-07  6:08   ` 赵振国
@ 2021-07-07  6:10   ` Greg KH
  1 sibling, 0 replies; 6+ messages in thread
From: Greg KH @ 2021-07-07  6:10 UTC (permalink / raw)
  To: 赵振国; +Cc: Jiri Slaby, linux-kernel

On Wed, Jul 07, 2021 at 02:02:54PM +0800, 赵振国 wrote:
> Dear Jiri,Greg

<snip>

still html :(

Please fix your email client, there are instructions on how to do that
in the Documentation/ directory.

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] tty: n_gsm: CR bit value should be 0 when config "initiator=0"
  2021-06-16 11:53 [PATCH v2] tty: n_gsm: CR bit value should be 0 when config "initiator=0" Zhenguo Zhao
  2021-06-24 12:58 ` Greg KH
       [not found] ` <CAGGV+3LgLdohhYhH+qJTokeNU_WdV9oRNHMc9a_5YTTVA3U8ow@mail.gmail.com>
@ 2021-07-07  6:12 ` 赵振国
  2021-07-15  2:29   ` 赵振国
  2 siblings, 1 reply; 6+ messages in thread
From: 赵振国 @ 2021-07-07  6:12 UTC (permalink / raw)
  To: 赵振国, Greg KH, Jiri Slaby; +Cc: linux-kernel

Dear Jiri,Greg

 1:   our development board uses linux kernel , uart dev node is "/dev/ttyGS2"
 2:   config uart "/dev/ttyGS2" ,we use ngsm ldisc,and config
"c.initiator = 0;" code is as follows

  #include <stdio.h>
  #include <stdint.h>
  #include <linux/gsmmux.h>
  #include <linux/tty.h>
  #define DEFAULT_SPEED      B115200
  #define SERIAL_PORT        /dev/ttyGS2

     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();

3:  connect to ubuntu by uart serial port cable,ubuntu uart dev node
is /"dev/ttyUSB0"
send  DLC0 SABM command by "/dev/ttyUSB0",but linux development board
can't response,code is as follows

int main(int argc, char **argv)
{
    int fd;
fd = open("/dev/ttyUSB0,O_RDWR | O_NOCTTY | O_NDELAY);
char buf[256]={0xf9,0x03,0x3f,0x01,0x1c,0xf9};
write(fd,buf,6);
close(fd);
}

4:  linux development board receive data,by uart,gsm_queue will check
CR,find CR=1.so go to invalid,pls check again.
static void gsm_queue(struct gsm_mux *gsm)
{
cr ^= 1 - gsm->initiator; /* Flip so 1 always means command */
dlci = gsm->dlci[address];

switch (gsm->control) {
case SABM|PF:
if (cr == 0)
goto invalid;
if (dlci == NULL)
dlci = gsm_dlci_alloc(gsm, address);
if (dlci == NULL)
return;
if (dlci->dead)
gsm_response(gsm, address, DM);
else {
gsm_response(gsm, address, UA);
gsm_dlci_open(dlci);
}
break;

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] tty: n_gsm: CR bit value should be 0 when config "initiator=0"
  2021-07-07  6:12 ` 赵振国
@ 2021-07-15  2:29   ` 赵振国
  0 siblings, 0 replies; 6+ messages in thread
From: 赵振国 @ 2021-07-15  2:29 UTC (permalink / raw)
  To: 赵振国, Greg KH, Jiri Slaby; +Cc: linux-kernel

Dear Jiri,Greg

ngsm as responser,pls review the process again.
because according to this process, it can't work.

Thanks!

赵振国 <zhenguo6858@gmail.com> 于2021年7月7日周三 下午2:12写道:
>
> Dear Jiri,Greg
>
>  1:   our development board uses linux kernel , uart dev node is "/dev/ttyGS2"
>  2:   config uart "/dev/ttyGS2" ,we use ngsm ldisc,and config
> "c.initiator = 0;" code is as follows
>
>   #include <stdio.h>
>   #include <stdint.h>
>   #include <linux/gsmmux.h>
>   #include <linux/tty.h>
>   #define DEFAULT_SPEED      B115200
>   #define SERIAL_PORT        /dev/ttyGS2
>
>      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();
>
> 3:  connect to ubuntu by uart serial port cable,ubuntu uart dev node
> is /"dev/ttyUSB0"
> send  DLC0 SABM command by "/dev/ttyUSB0",but linux development board
> can't response,code is as follows
>
> int main(int argc, char **argv)
> {
>     int fd;
> fd = open("/dev/ttyUSB0,O_RDWR | O_NOCTTY | O_NDELAY);
> char buf[256]={0xf9,0x03,0x3f,0x01,0x1c,0xf9};
> write(fd,buf,6);
> close(fd);
> }
>
> 4:  linux development board receive data,by uart,gsm_queue will check
> CR,find CR=1.so go to invalid,pls check again.
> static void gsm_queue(struct gsm_mux *gsm)
> {
> cr ^= 1 - gsm->initiator; /* Flip so 1 always means command */
> dlci = gsm->dlci[address];
>
> switch (gsm->control) {
> case SABM|PF:
> if (cr == 0)
> goto invalid;
> if (dlci == NULL)
> dlci = gsm_dlci_alloc(gsm, address);
> if (dlci == NULL)
> return;
> if (dlci->dead)
> gsm_response(gsm, address, DM);
> else {
> gsm_response(gsm, address, UA);
> gsm_dlci_open(dlci);
> }
> break;

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-15  2:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16 11:53 [PATCH v2] tty: n_gsm: CR bit value should be 0 when config "initiator=0" Zhenguo Zhao
2021-06-24 12:58 ` Greg KH
     [not found] ` <CAGGV+3LgLdohhYhH+qJTokeNU_WdV9oRNHMc9a_5YTTVA3U8ow@mail.gmail.com>
2021-07-07  6:08   ` 赵振国
2021-07-07  6:10   ` Greg KH
2021-07-07  6:12 ` 赵振国
2021-07-15  2:29   ` 赵振国

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.