master
  1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2/* Copyright (c) 2022/23 Siemens Mobility GmbH */
  3#ifndef _LINUX_GSMMUX_H
  4#define _LINUX_GSMMUX_H
  5
  6#include <linux/const.h>
  7#include <linux/if.h>
  8#include <linux/ioctl.h>
  9#include <linux/types.h>
 10
 11/*
 12 * flags definition for n_gsm
 13 *
 14 * Used by:
 15 * struct gsm_config_ext.flags
 16 * struct gsm_dlci_config.flags
 17 */
 18/* Forces a DLCI reset if set. Otherwise, a DLCI reset is only done if
 19 * incompatible settings were provided. Always cleared on retrieval.
 20 */
 21#define GSM_FL_RESTART	_BITUL(0)
 22
 23/**
 24 * struct gsm_config - n_gsm basic configuration parameters
 25 *
 26 * This structure is used in combination with GSMIOC_GETCONF and GSMIOC_SETCONF
 27 * to retrieve and set the basic parameters of an n_gsm ldisc.
 28 * struct gsm_config_ext can be used to configure extended ldisc parameters.
 29 *
 30 * All timers are in units of 1/100th of a second.
 31 *
 32 * @adaption:      Convergence layer type
 33 * @encapsulation: Framing (0 = basic option, 1 = advanced option)
 34 * @initiator:     Initiator or responder
 35 * @t1:            Acknowledgment timer
 36 * @t2:            Response timer for multiplexer control channel
 37 * @t3:            Response timer for wake-up procedure
 38 * @n2:            Maximum number of retransmissions
 39 * @mru:           Maximum incoming frame payload size
 40 * @mtu:           Maximum outgoing frame payload size
 41 * @k:             Window size
 42 * @i:             Frame type (1 = UIH, 2 = UI)
 43 * @unused:        Can not be used
 44 */
 45struct gsm_config
 46{
 47	unsigned int adaption;
 48	unsigned int encapsulation;
 49	unsigned int initiator;
 50	unsigned int t1;
 51	unsigned int t2;
 52	unsigned int t3;
 53	unsigned int n2;
 54	unsigned int mru;
 55	unsigned int mtu;
 56	unsigned int k;
 57	unsigned int i;
 58	unsigned int unused[8];
 59};
 60
 61#define GSMIOC_GETCONF		_IOR('G', 0, struct gsm_config)
 62#define GSMIOC_SETCONF		_IOW('G', 1, struct gsm_config)
 63
 64/**
 65 * struct gsm_netconfig - n_gsm network configuration parameters
 66 *
 67 * This structure is used in combination with GSMIOC_ENABLE_NET and
 68 * GSMIOC_DISABLE_NET to enable or disable a network data connection
 69 * over a mux virtual tty channel. This is for modems that support
 70 * data connections with raw IP frames instead of PPP.
 71 *
 72 * @adaption: Adaption to use in network mode.
 73 * @protocol: Protocol to use - only ETH_P_IP supported.
 74 * @unused2:  Can not be used.
 75 * @if_name:  Interface name format string.
 76 * @unused:   Can not be used.
 77 */
 78struct gsm_netconfig {
 79	unsigned int adaption;
 80	unsigned short protocol;
 81	unsigned short unused2;
 82	char if_name[IFNAMSIZ];
 83	__u8 unused[28];
 84};
 85
 86#define GSMIOC_ENABLE_NET      _IOW('G', 2, struct gsm_netconfig)
 87#define GSMIOC_DISABLE_NET     _IO('G', 3)
 88
 89/* get the base tty number for a configured gsmmux tty */
 90#define GSMIOC_GETFIRST		_IOR('G', 4, __u32)
 91
 92/**
 93 * struct gsm_config_ext - n_gsm extended configuration parameters
 94 *
 95 * This structure is used in combination with GSMIOC_GETCONF_EXT and
 96 * GSMIOC_SETCONF_EXT to retrieve and set the extended parameters of an
 97 * n_gsm ldisc.
 98 *
 99 * All timers are in units of 1/100th of a second.
100 *
101 * @keep_alive:  Control channel keep-alive in 1/100th of a second (0 to disable).
102 * @wait_config: Wait for DLCI config before opening virtual link?
103 * @flags:       Mux specific flags.
104 * @reserved:    For future use, must be initialized to zero.
105 */
106struct gsm_config_ext {
107	__u32 keep_alive;
108	__u32 wait_config;
109	__u32 flags;
110	__u32 reserved[5];
111};
112
113#define GSMIOC_GETCONF_EXT	_IOR('G', 5, struct gsm_config_ext)
114#define GSMIOC_SETCONF_EXT	_IOW('G', 6, struct gsm_config_ext)
115
116/**
117 * struct gsm_dlci_config - n_gsm channel configuration parameters
118 *
119 * This structure is used in combination with GSMIOC_GETCONF_DLCI and
120 * GSMIOC_SETCONF_DLCI to retrieve and set the channel specific parameters
121 * of an n_gsm ldisc.
122 *
123 * Set the channel accordingly before calling GSMIOC_GETCONF_DLCI.
124 *
125 * @channel:  DLCI (0 for the associated DLCI).
126 * @adaption: Convergence layer type.
127 * @mtu:      Maximum transfer unit.
128 * @priority: Priority (0 for default value).
129 * @i:        Frame type (1 = UIH, 2 = UI).
130 * @k:        Window size (0 for default value).
131 * @flags:    DLCI specific flags.
132 * @reserved: For future use, must be initialized to zero.
133 */
134struct gsm_dlci_config {
135	__u32 channel;
136	__u32 adaption;
137	__u32 mtu;
138	__u32 priority;
139	__u32 i;
140	__u32 k;
141	__u32 flags;
142	__u32 reserved[7];
143};
144
145#define GSMIOC_GETCONF_DLCI	_IOWR('G', 7, struct gsm_dlci_config)
146#define GSMIOC_SETCONF_DLCI	_IOW('G', 8, struct gsm_dlci_config)
147
148#endif