master
  1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2/* linux/caif_socket.h
  3 * CAIF Definitions for CAIF socket and network layer
  4 * Copyright (C) ST-Ericsson AB 2010
  5 * Author:	 Sjur Brendeland
  6 * License terms: GNU General Public License (GPL) version 2
  7 */
  8
  9#ifndef _LINUX_CAIF_SOCKET_H
 10#define _LINUX_CAIF_SOCKET_H
 11
 12#include <linux/types.h>
 13#include <linux/socket.h>
 14
 15/**
 16 * enum caif_link_selector -    Physical Link Selection.
 17 * @CAIF_LINK_HIGH_BANDW:	Physical interface for high-bandwidth
 18 *				traffic.
 19 * @CAIF_LINK_LOW_LATENCY:	Physical interface for low-latency
 20 *				traffic.
 21 *
 22 * CAIF Link Layers can register their link properties.
 23 * This enum is used for choosing between CAIF Link Layers when
 24 * setting up CAIF Channels when multiple CAIF Link Layers exists.
 25 */
 26enum caif_link_selector {
 27	CAIF_LINK_HIGH_BANDW,
 28	CAIF_LINK_LOW_LATENCY
 29};
 30
 31/**
 32 * enum caif_channel_priority - CAIF channel priorities.
 33 *
 34 * @CAIF_PRIO_MIN:	Min priority for a channel.
 35 * @CAIF_PRIO_LOW:	Low-priority channel.
 36 * @CAIF_PRIO_NORMAL:	Normal/default priority level.
 37 * @CAIF_PRIO_HIGH:	High priority level
 38 * @CAIF_PRIO_MAX:	Max priority for channel
 39 *
 40 * Priority can be set on CAIF Channels in order to
 41 * prioritize between traffic on different CAIF Channels.
 42 * These priority levels are recommended, but the priority value
 43 * is not restricted to the values defined in this enum, any value
 44 * between CAIF_PRIO_MIN and CAIF_PRIO_MAX could be used.
 45 */
 46enum caif_channel_priority {
 47	CAIF_PRIO_MIN	 = 0x01,
 48	CAIF_PRIO_LOW	 = 0x04,
 49	CAIF_PRIO_NORMAL = 0x0f,
 50	CAIF_PRIO_HIGH	 = 0x14,
 51	CAIF_PRIO_MAX	 = 0x1F
 52};
 53
 54/**
 55 * enum caif_protocol_type  -	CAIF Channel type.
 56 * @CAIFPROTO_AT:		Classic AT channel.
 57 * @CAIFPROTO_DATAGRAM:	Datagram channel.
 58 * @CAIFPROTO_DATAGRAM_LOOP:	Datagram loopback channel, used for testing.
 59 * @CAIFPROTO_UTIL:		Utility (Psock) channel.
 60 * @CAIFPROTO_RFM:		Remote File Manager
 61 * @CAIFPROTO_DEBUG:		Debug link
 62 *
 63 * This enum defines the CAIF Channel type to be used. This defines
 64 * the service to connect to on the modem.
 65 */
 66enum caif_protocol_type {
 67	CAIFPROTO_AT,
 68	CAIFPROTO_DATAGRAM,
 69	CAIFPROTO_DATAGRAM_LOOP,
 70	CAIFPROTO_UTIL,
 71	CAIFPROTO_RFM,
 72	CAIFPROTO_DEBUG,
 73	_CAIFPROTO_MAX
 74};
 75#define	CAIFPROTO_MAX _CAIFPROTO_MAX
 76
 77/**
 78 * enum caif_at_type - AT Service Endpoint
 79 * @CAIF_ATTYPE_PLAIN:	     Connects to a plain vanilla AT channel.
 80 */
 81enum caif_at_type {
 82	CAIF_ATTYPE_PLAIN = 2
 83};
 84 /**
 85 * enum caif_debug_type - Content selection for debug connection
 86 * @CAIF_DEBUG_TRACE_INTERACTIVE: Connection will contain
 87 *				both trace and interactive debug.
 88 * @CAIF_DEBUG_TRACE:		Connection contains trace only.
 89 * @CAIF_DEBUG_INTERACTIVE:	Connection to interactive debug.
 90 */
 91enum caif_debug_type {
 92	CAIF_DEBUG_TRACE_INTERACTIVE = 0,
 93	CAIF_DEBUG_TRACE,
 94	CAIF_DEBUG_INTERACTIVE,
 95};
 96
 97/**
 98 * enum caif_debug_service - Debug Service Endpoint
 99 * @CAIF_RADIO_DEBUG_SERVICE:	Debug service on the Radio sub-system
100 * @CAIF_APP_DEBUG_SERVICE:	Debug for the applications sub-system
101 */
102enum caif_debug_service {
103	CAIF_RADIO_DEBUG_SERVICE = 1,
104	CAIF_APP_DEBUG_SERVICE
105};
106
107/**
108 * struct sockaddr_caif - the sockaddr structure for CAIF sockets.
109 * @family:		     Address family number, must be AF_CAIF.
110 * @u:			     Union of address data 'switched' by family.
111 * :
112 * @u.at:                    Applies when family = CAIFPROTO_AT.
113 *
114 * @u.at.type:               Type of AT link to set up (enum caif_at_type).
115 *
116 * @u.util:                  Applies when family = CAIFPROTO_UTIL
117 *
118 * @u.util.service:          Utility service name.
119 *
120 * @u.dgm:                   Applies when family = CAIFPROTO_DATAGRAM
121 *
122 * @u.dgm.connection_id:     Datagram connection id.
123 *
124 * @u.dgm.nsapi:             NSAPI of the PDP-Context.
125 *
126 * @u.rfm:                   Applies when family = CAIFPROTO_RFM
127 *
128 * @u.rfm.connection_id:     Connection ID for RFM.
129 *
130 * @u.rfm.volume:            Volume to mount.
131 *
132 * @u.dbg:		      Applies when family = CAIFPROTO_DEBUG.
133 *
134 * @u.dbg.type:			     Type of debug connection to set up
135 *			      (caif_debug_type).
136 *
137 * @u.dbg.service:	      Service sub-system to connect (caif_debug_service
138 * Description:
139 * This structure holds the connect parameters used for setting up a
140 * CAIF Channel. It defines the service to connect to on the modem.
141 */
142struct sockaddr_caif {
143	__kernel_sa_family_t  family;
144	union {
145		struct {
146			__u8  type;		/* type: enum caif_at_type */
147		} at;				/* CAIFPROTO_AT */
148		struct {
149			char	  service[16];
150		} util;				/* CAIFPROTO_UTIL */
151		union {
152			__u32 connection_id;
153			__u8  nsapi;
154		} dgm;				/* CAIFPROTO_DATAGRAM(_LOOP)*/
155		struct {
156			__u32 connection_id;
157			char	  volume[16];
158		} rfm;				/* CAIFPROTO_RFM */
159		struct {
160			__u8  type;		/* type:enum caif_debug_type */
161			__u8  service;		/* service:caif_debug_service */
162		} dbg;				/* CAIFPROTO_DEBUG */
163	} u;
164};
165
166/**
167 * enum caif_socket_opts - CAIF option values for getsockopt and setsockopt.
168 *
169 * @CAIFSO_LINK_SELECT:		Selector used if multiple CAIF Link layers are
170 *				available. Either a high bandwidth
171 *				link can be selected (CAIF_LINK_HIGH_BANDW) or
172 *				a low latency link (CAIF_LINK_LOW_LATENCY).
173 *                              This option is of type __u32.
174 *				Alternatively SO_BINDTODEVICE can be used.
175 *
176 * @CAIFSO_REQ_PARAM:		Used to set the request parameters for a
177 *				utility channel. (maximum 256 bytes). This
178 *				option must be set before connecting.
179 *
180 * @CAIFSO_RSP_PARAM:		Gets the response parameters for a utility
181 *				channel. (maximum 256 bytes). This option
182 *				is valid after a successful connect.
183 *
184 *
185 * This enum defines the CAIF Socket options to be used on a socket
186 * of type PF_CAIF.
187 *
188 */
189enum caif_socket_opts {
190	CAIFSO_LINK_SELECT	= 127,
191	CAIFSO_REQ_PARAM	= 128,
192	CAIFSO_RSP_PARAM	= 129,
193};
194
195#endif /* _LINUX_CAIF_SOCKET_H */