All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrej Krpic <ak77@tnode.com>
To: xinhuix.pan@intel.com
Cc: linux-kernel@vger.kernel.org, jslaby@suse.com,
	gregkh@linuxfoundation.org, Andrej Krpic <ak77@tnode.com>
Subject: [PATCH 3/8] tty: n_gsm: make mux work as a responder station
Date: Mon, 22 Feb 2016 23:53:11 +0100	[thread overview]
Message-ID: <1456181596-11736-4-git-send-email-ak77@tnode.com> (raw)
In-Reply-To: <1456181596-11736-1-git-send-email-ak77@tnode.com>

Comment suggests that cr == 1 represents a received command and cr == 0
a received response. Received frames are then filtered:
 - correctly by rejection of SABM and DISC responses, they are
   command only frame types and
 - incorrectly by rejection of UA (a response only frame type) responses.

Mux as a initiator successfully establishes DLC by receiving UA response
frame to a previously sent open channel command (SABM). Incorrect
equation (eqA) makes UA "reject cr == 0 commands" case correct, but
filters out all received SABM and DISC command frames.

Change eqA to eqB to match the intent and fix filtering of UA frames.
This enables reception of SABM and DISC frames and consequently
makes mux  work as a responder station.

received    receiving as          eqA          eqB       3GPP TS 27.010
 CR bit     initiator (ir)    cr=CR^(1-ir)   cr=CR^ir        5.2.1.2
   0              0                 1            0         0 (response)
   1              0         _\      0            1         1 (command)
   0              1          /      0            1         1 (command)
   1              1                 1            0         0 (response)

Signed-off-by: Andrej Krpic <ak77@tnode.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 a0fb92c..05b562d 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -1798,7 +1798,7 @@ static void gsm_queue(struct gsm_mux *gsm)
 
 	gsm_print_packet("<--", address, cr, gsm->control, gsm->buf, gsm->len);
 
-	cr ^= 1 - gsm->initiator;	/* Flip so 1 always means command */
+	cr ^= gsm->initiator;		/* Flip so 1 always means command */
 	dlci = gsm->dlci[address];
 
 	switch (gsm->control) {
@@ -1829,7 +1829,7 @@ static void gsm_queue(struct gsm_mux *gsm)
 		break;
 	case UA:
 	case UA|PF:
-		if (cr == 0 || dlci == NULL)
+		if (cr || dlci == NULL)
 			break;
 		switch (dlci->state) {
 		case DLCI_CLOSING:
-- 
2.7.0

  parent reply	other threads:[~2016-02-22 22:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-22 22:53 [PATCH 0/8] tty: n_gsm: Make mux work as a responder station Andrej Krpic
2016-02-22 22:53 ` [PATCH 1/8] tty: n_gsm: fix formatting errors Andrej Krpic
2016-02-22 22:53 ` [PATCH 2/8] tty: n_gsm: fix C/R bit when sending as a responder Andrej Krpic
2016-02-22 22:53 ` Andrej Krpic [this message]
2016-02-22 22:53 ` [PATCH 4/8] tty: n_gsm: send DM response when accessing an invalid channel Andrej Krpic
2016-02-22 22:53 ` [PATCH 5/8] tty: n_gsm: replace dead code with a meaningful comment Andrej Krpic
2016-02-22 22:53 ` [PATCH 6/8] tty: n_gsm: add missing length field in control channel commands Andrej Krpic
2016-02-22 22:53 ` [PATCH 7/8] tty: n_gsm: properly format Modem Status Command message Andrej Krpic
2016-02-22 22:53 ` [PATCH 8/8] tty: n_gsm: Enable reception of frames separated with a single SOF marker Andrej Krpic
2016-02-22 23:39 ` [PATCH 0/8] tty: n_gsm: Make mux work as a responder station *DUPLICATE* Andrej Krpic
  -- strict thread matches above, loose matches on Subject: below --
2016-02-21 21:38 [PATCH 0/8] tty: n_gsm: Make mux work as a responder station Andrej Krpic
2016-02-21 21:38 ` [PATCH 3/8] tty: n_gsm: make " Andrej Krpic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1456181596-11736-4-git-send-email-ak77@tnode.com \
    --to=ak77@tnode.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xinhuix.pan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.