From: Jiri Slaby <jirislaby@kernel.org>
To: "D. Starke" <daniel.starke@siemens.com>,
linux-serial@vger.kernel.org, gregkh@linuxfoundation.org,
ilpo.jarvinen@linux.intel.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] tty: n_gsm: add ioctl for DLC specific parameter configuration
Date: Tue, 28 Feb 2023 07:58:48 +0100 [thread overview]
Message-ID: <7ad445d4-34b5-0973-1f4e-7413feabb206@kernel.org> (raw)
In-Reply-To: <20230228062957.3150-1-daniel.starke@siemens.com>
On 28. 02. 23, 7:29, D. Starke wrote:
> From: Daniel Starke <daniel.starke@siemens.com>
>
> Parameter negotiation has been introduced with
> commit 92f1f0c3290d ("tty: n_gsm: add parameter negotiation support")
>
> However, means to set individual parameters per DLCI are not yet
> implemented. Furthermore, it is currently not possible to keep a DLCI half
> open until the user application sets the right parameters for it. This is
> required to allow a user application to set its specific parameters before
> the underlying link is established. Otherwise, the link is opened and
> re-established right afterwards if the user application sets incompatible
> parameters. This may be an unexpected behavior for the peer.
>
> Add parameter 'wait_config' to 'gsm_config' to support setups where the
> DLCI specific user application sets its specific parameters after open()
> and before the link gets fully established. Setting this to zero disables
> the user application specific DLCI configuration option.
>
> Add the ioctls 'GSMIOC_GETCONF_DLCI' and 'GSMIOC_SETCONF_DLCI' for the
> ldisc and virtual ttys. This gets/sets the DLCI specific parameters and may
> trigger a reconnect of the DLCI if incompatible values have been set. Only
> the parameters for the DLCI associated with the virtual tty can be set or
> retrieved if called on these.
>
> Add remark within the documentation to introduce the new ioctls.
>
> Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
...
> @@ -2453,6 +2476,128 @@ static void gsm_kick_timer(struct timer_list *t)
> pr_info("%s TX queue stalled\n", __func__);
> }
>
> +/**
> + * gsm_dlci_copy_config_values - copy DLCI configuration
> + * @dlci: source DLCI
> + * @dc: configuration structure to fill
> + */
> +static void gsm_dlci_copy_config_values(struct gsm_dlci *dlci, struct gsm_dlci_config *dc)
> +{
> + memset(dc, 0, sizeof(*dc));
> + dc->channel = (u32)dlci->addr;
> + dc->adaption = (u32)dlci->adaption;
> + dc->mtu = (u32)dlci->mtu;
> + dc->priority = (u32)dlci->prio;
> + if (dlci->ftype == UIH)
> + dc->i = 1;
> + else
> + dc->i = 2;
> + dc->k = (u32)dlci->k;
Why all those casts?
> +}
> +
> +/**
> + * gsm_dlci_config - configure DLCI from configuration
> + * @dlci: DLCI to configure
> + * @dc: DLCI configuration
> + * @open: open DLCI after configuration?
> + */
> +static int gsm_dlci_config(struct gsm_dlci *dlci, struct gsm_dlci_config *dc, int open)
> +{
> + struct gsm_mux *gsm;
> + bool need_restart = false;
> + bool need_open = false;
> + unsigned int i;
> +
> + /*
> + * Check that userspace doesn't put stuff in here to prevent breakages
> + * in the future.
> + */
> + for (i = 0; i < ARRAY_SIZE(dc->reserved); i++)
> + if (dc->reserved[i])
> + return -EINVAL;
> +
> + if (!dlci)
> + return -EINVAL;
> + gsm = dlci->gsm;
> +
> + /* Stuff we don't support yet - I frame transport */
> + if (dc->adaption != 1 && dc->adaption != 2)
> + return -EOPNOTSUPP;
> + if (dc->mtu > MAX_MTU || dc->mtu < MIN_MTU || (unsigned int)dc->mtu > gsm->mru)
> + return -EINVAL;
> + if (dc->priority >= 64)
> + return -EINVAL;
> + if (dc->i == 0 || dc->i > 2) /* UIH and UI only */
> + return -EINVAL;
> + if (dc->k > 7)
> + return -EINVAL;
> +
> + /*
> + * See what is needed for reconfiguration
> + */
> + /* Framing fields */
> + if ((int)dc->adaption != dlci->adaption)
> + need_restart = true;
> + if ((unsigned int)dc->mtu != dlci->mtu)
> + need_restart = true;
> + if ((u8)dc->i != dlci->ftype)
> + need_restart = true;
> + /* Requires care */
> + if ((u8)dc->priority != (u32)dlci->prio)
> + need_restart = true;
And here.
> +
> + if ((open && gsm->wait_config) || need_restart)
> + need_open = true;
> + if (dlci->state == DLCI_WAITING_CONFIG) {
> + need_restart = false;
> + need_open = true;
> + }
> +
> + /*
> + * Close down what is needed, restart and initiate the new
> + * configuration.
> + */
> + if (need_restart) {
> + gsm_dlci_begin_close(dlci);
> + wait_event_interruptible(gsm->event, dlci->state == DLCI_CLOSED);
> + if (signal_pending(current))
> + return -EINTR;
> + }
> + /*
> + * Setup the new configuration values
> + */
> + dlci->adaption = (int)dc->adaption;
> +
> + if (dlci->mtu)
dc->mtu?
> + dlci->mtu = (unsigned int)dc->mtu;
> + else
> + dlci->mtu = gsm->mtu;
> +
> + if (dc->priority)
> + dlci->prio = (u8)dc->priority;
> + else
> + dlci->prio = roundup(dlci->addr + 1, 8) - 1;
> +
> + if (dc->i == 1)
> + dlci->ftype = UIH;
> + else if (dc->i == 2)
> + dlci->ftype = UI;
> +
> + if (dc->k)
> + dlci->k = (u8)dc->k;
> + else
> + dlci->k = gsm->k;
> +
> + if (need_open) {
> + if (gsm->initiator)
> + gsm_dlci_begin_open(dlci);
> + else
> + gsm_dlci_set_opening(dlci);
> + }
> +
> + return 0;
> +}
> +
> /*
> * Allocate/Free DLCI channels
> */
--
js
suse labs
next prev parent reply other threads:[~2023-02-28 6:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 6:29 D. Starke
2023-02-28 6:29 ` [PATCH 2/3] tty: n_gsm: allow window size configuration D. Starke
2023-02-28 6:29 ` [PATCH 3/3] tty: n_gsm: add ioctl for DLC config via ldisc handle D. Starke
2023-02-28 6:58 ` Jiri Slaby [this message]
2023-02-28 7:08 ` [PATCH 1/3] tty: n_gsm: add ioctl for DLC specific parameter configuration Starke, Daniel
2023-02-28 10:51 ` kernel test robot
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=7ad445d4-34b5-0973-1f4e-7413feabb206@kernel.org \
--to=jirislaby@kernel.org \
--cc=daniel.starke@siemens.com \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®