^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) ST-Ericsson AB 2010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Author: Sjur Brendeland
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #ifndef CFCTRL_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define CFCTRL_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <net/caif/caif_layer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <net/caif/cfsrvl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /* CAIF Control packet commands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) enum cfctrl_cmd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) CFCTRL_CMD_LINK_SETUP = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) CFCTRL_CMD_LINK_DESTROY = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) CFCTRL_CMD_LINK_ERR = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) CFCTRL_CMD_ENUM = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) CFCTRL_CMD_SLEEP = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) CFCTRL_CMD_WAKE = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) CFCTRL_CMD_LINK_RECONF = 6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) CFCTRL_CMD_START_REASON = 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) CFCTRL_CMD_RADIO_SET = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) CFCTRL_CMD_MODEM_SET = 9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) CFCTRL_CMD_MASK = 0xf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /* Channel types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) enum cfctrl_srv {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) CFCTRL_SRV_DECM = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) CFCTRL_SRV_VEI = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) CFCTRL_SRV_VIDEO = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) CFCTRL_SRV_DBG = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) CFCTRL_SRV_DATAGRAM = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) CFCTRL_SRV_RFM = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) CFCTRL_SRV_UTIL = 6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) CFCTRL_SRV_MASK = 0xf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define CFCTRL_RSP_BIT 0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define CFCTRL_ERR_BIT 0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct cfctrl_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) void (*linksetup_rsp)(struct cflayer *layer, u8 linkid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) enum cfctrl_srv serv, u8 phyid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct cflayer *adapt_layer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) void (*linkdestroy_rsp)(struct cflayer *layer, u8 linkid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) void (*linkerror_ind)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) void (*enum_rsp)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) void (*sleep_rsp)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) void (*wake_rsp)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) void (*restart_rsp)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) void (*radioset_rsp)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) void (*reject_rsp)(struct cflayer *layer, u8 linkid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct cflayer *client_layer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /* Link Setup Parameters for CAIF-Links. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct cfctrl_link_param {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) enum cfctrl_srv linktype;/* (T3,T0) Type of Channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) u8 priority; /* (P4,P0) Priority of the channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) u8 phyid; /* (U2-U0) Physical interface to connect */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) u8 endpoint; /* (E1,E0) Endpoint for data channels */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) u8 chtype; /* (H1,H0) Channel-Type, applies to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * VEI, DEBUG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) u8 connid; /* (D7,D0) Video LinkId */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) } video;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) u32 connid; /* (N31,Ngit0) Connection ID used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * for Datagram */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) } datagram;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) u32 connid; /* Connection ID used for RFM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) char volume[20]; /* Volume to mount for RFM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) } rfm; /* Configuration for RFM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) u16 fifosize_kb; /* Psock FIFO size in KB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) u16 fifosize_bufs; /* Psock # signal buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) char name[16]; /* Name of the PSOCK service */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) u8 params[255]; /* Link setup Parameters> */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) u16 paramlen; /* Length of Link Setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * Parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) } utility; /* Configuration for Utility Links (Psock) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) } u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /* This structure is used internally in CFCTRL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) struct cfctrl_request_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) int sequence_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) enum cfctrl_cmd cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) u8 channel_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) struct cfctrl_link_param param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct cflayer *client_layer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct cfctrl {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct cfsrvl serv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct cfctrl_rsp res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) atomic_t req_seq_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) atomic_t rsp_seq_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /* Protects from simultaneous access to first_req list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) spinlock_t info_list_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #ifndef CAIF_NO_LOOP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) u8 loop_linkid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) int loop_linkused[256];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /* Protects simultaneous access to loop_linkid and loop_linkused */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) spinlock_t loop_linkid_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) void cfctrl_enum_req(struct cflayer *cfctrl, u8 physlinkid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) int cfctrl_linkup_request(struct cflayer *cfctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) struct cfctrl_link_param *param,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct cflayer *user_layer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) int cfctrl_linkdown_req(struct cflayer *cfctrl, u8 linkid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) struct cflayer *client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) struct cflayer *cfctrl_create(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) struct cfctrl_rsp *cfctrl_get_respfuncs(struct cflayer *layer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) int cfctrl_cancel_req(struct cflayer *layr, struct cflayer *adap_layer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) void cfctrl_remove(struct cflayer *layr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #endif /* CFCTRL_H_ */