Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) ST-Ericsson AB 2010 |
sjur.brandeland@stericsson.com | 26ee65e | 2013-04-22 23:57:01 +0000 | [diff] [blame] | 3 | * Author: Sjur Brendeland |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 4 | * License terms: GNU General Public License (GPL) version 2 |
| 5 | */ |
| 6 | |
Joe Perches | b31fa5b | 2010-09-05 21:31:11 +0000 | [diff] [blame] | 7 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s(): " fmt, __func__ |
| 8 | |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 9 | #include <linux/stddef.h> |
| 10 | #include <linux/spinlock.h> |
| 11 | #include <linux/slab.h> |
Dmitry Tarnyagin | 4476481 | 2012-04-12 08:27:24 +0000 | [diff] [blame] | 12 | #include <linux/pkt_sched.h> |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 13 | #include <net/caif/caif_layer.h> |
| 14 | #include <net/caif/cfpkt.h> |
| 15 | #include <net/caif/cfctrl.h> |
| 16 | |
| 17 | #define container_obj(layr) container_of(layr, struct cfctrl, serv.layer) |
| 18 | #define UTILITY_NAME_LENGTH 16 |
| 19 | #define CFPKT_CTRL_PKT_LEN 20 |
| 20 | |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 21 | #ifdef CAIF_NO_LOOP |
| 22 | static int handle_loop(struct cfctrl *ctrl, |
Silviu-Mihai Popescu | 3bffc47 | 2013-03-06 19:39:57 +0000 | [diff] [blame] | 23 | int cmd, struct cfpkt *pkt){ |
Sjur Braendeland | 2aa40ae | 2010-06-17 06:55:40 +0000 | [diff] [blame] | 24 | return -1; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 25 | } |
| 26 | #else |
| 27 | static int handle_loop(struct cfctrl *ctrl, |
Silviu-Mihai Popescu | 3bffc47 | 2013-03-06 19:39:57 +0000 | [diff] [blame] | 28 | int cmd, struct cfpkt *pkt); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 29 | #endif |
| 30 | static int cfctrl_recv(struct cflayer *layr, struct cfpkt *pkt); |
| 31 | static void cfctrl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl, |
| 32 | int phyid); |
| 33 | |
| 34 | |
| 35 | struct cflayer *cfctrl_create(void) |
| 36 | { |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 37 | struct dev_info dev_info; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 38 | struct cfctrl *this = |
Joe Perches | 7ac2ed0 | 2011-08-25 13:22:24 +0000 | [diff] [blame] | 39 | kzalloc(sizeof(struct cfctrl), GFP_ATOMIC); |
| 40 | if (!this) |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 41 | return NULL; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 42 | caif_assert(offsetof(struct cfctrl, serv.layer) == 0); |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 43 | memset(&dev_info, 0, sizeof(dev_info)); |
| 44 | dev_info.id = 0xff; |
Sjur Braendeland | b1c7424 | 2010-06-17 06:55:38 +0000 | [diff] [blame] | 45 | cfsrvl_init(&this->serv, 0, &dev_info, false); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 46 | atomic_set(&this->req_seq_no, 1); |
| 47 | atomic_set(&this->rsp_seq_no, 1); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 48 | this->serv.layer.receive = cfctrl_recv; |
| 49 | sprintf(this->serv.layer.name, "ctrl"); |
| 50 | this->serv.layer.ctrlcmd = cfctrl_ctrlcmd; |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 51 | #ifndef CAIF_NO_LOOP |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 52 | spin_lock_init(&this->loop_linkid_lock); |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 53 | this->loop_linkid = 1; |
| 54 | #endif |
Sjur Braendeland | 7aecf49 | 2010-05-21 02:16:08 +0000 | [diff] [blame] | 55 | spin_lock_init(&this->info_list_lock); |
| 56 | INIT_LIST_HEAD(&this->list); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 57 | return &this->serv.layer; |
| 58 | } |
| 59 | |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 60 | void cfctrl_remove(struct cflayer *layer) |
| 61 | { |
| 62 | struct cfctrl_request_info *p, *tmp; |
| 63 | struct cfctrl *ctrl = container_obj(layer); |
| 64 | |
| 65 | spin_lock_bh(&ctrl->info_list_lock); |
| 66 | list_for_each_entry_safe(p, tmp, &ctrl->list, list) { |
| 67 | list_del(&p->list); |
| 68 | kfree(p); |
| 69 | } |
| 70 | spin_unlock_bh(&ctrl->info_list_lock); |
| 71 | kfree(layer); |
| 72 | } |
| 73 | |
Stephen Hemminger | 73d6ac6 | 2011-04-11 10:43:50 +0000 | [diff] [blame] | 74 | static bool param_eq(const struct cfctrl_link_param *p1, |
Silviu-Mihai Popescu | 3bffc47 | 2013-03-06 19:39:57 +0000 | [diff] [blame] | 75 | const struct cfctrl_link_param *p2) |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 76 | { |
| 77 | bool eq = |
| 78 | p1->linktype == p2->linktype && |
| 79 | p1->priority == p2->priority && |
| 80 | p1->phyid == p2->phyid && |
| 81 | p1->endpoint == p2->endpoint && p1->chtype == p2->chtype; |
| 82 | |
| 83 | if (!eq) |
| 84 | return false; |
| 85 | |
| 86 | switch (p1->linktype) { |
| 87 | case CFCTRL_SRV_VEI: |
| 88 | return true; |
| 89 | case CFCTRL_SRV_DATAGRAM: |
| 90 | return p1->u.datagram.connid == p2->u.datagram.connid; |
| 91 | case CFCTRL_SRV_RFM: |
| 92 | return |
| 93 | p1->u.rfm.connid == p2->u.rfm.connid && |
| 94 | strcmp(p1->u.rfm.volume, p2->u.rfm.volume) == 0; |
| 95 | case CFCTRL_SRV_UTIL: |
| 96 | return |
| 97 | p1->u.utility.fifosize_kb == p2->u.utility.fifosize_kb |
| 98 | && p1->u.utility.fifosize_bufs == |
| 99 | p2->u.utility.fifosize_bufs |
| 100 | && strcmp(p1->u.utility.name, p2->u.utility.name) == 0 |
| 101 | && p1->u.utility.paramlen == p2->u.utility.paramlen |
| 102 | && memcmp(p1->u.utility.params, p2->u.utility.params, |
| 103 | p1->u.utility.paramlen) == 0; |
| 104 | |
| 105 | case CFCTRL_SRV_VIDEO: |
| 106 | return p1->u.video.connid == p2->u.video.connid; |
| 107 | case CFCTRL_SRV_DBG: |
| 108 | return true; |
| 109 | case CFCTRL_SRV_DECM: |
| 110 | return false; |
| 111 | default: |
| 112 | return false; |
| 113 | } |
| 114 | return false; |
| 115 | } |
| 116 | |
Stephen Hemminger | 73d6ac6 | 2011-04-11 10:43:50 +0000 | [diff] [blame] | 117 | static bool cfctrl_req_eq(const struct cfctrl_request_info *r1, |
| 118 | const struct cfctrl_request_info *r2) |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 119 | { |
| 120 | if (r1->cmd != r2->cmd) |
| 121 | return false; |
| 122 | if (r1->cmd == CFCTRL_CMD_LINK_SETUP) |
| 123 | return param_eq(&r1->param, &r2->param); |
| 124 | else |
| 125 | return r1->channel_id == r2->channel_id; |
| 126 | } |
| 127 | |
| 128 | /* Insert request at the end */ |
Stephen Hemminger | 73d6ac6 | 2011-04-11 10:43:50 +0000 | [diff] [blame] | 129 | static void cfctrl_insert_req(struct cfctrl *ctrl, |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 130 | struct cfctrl_request_info *req) |
| 131 | { |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 132 | spin_lock_bh(&ctrl->info_list_lock); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 133 | atomic_inc(&ctrl->req_seq_no); |
| 134 | req->sequence_no = atomic_read(&ctrl->req_seq_no); |
Sjur Braendeland | 7aecf49 | 2010-05-21 02:16:08 +0000 | [diff] [blame] | 135 | list_add_tail(&req->list, &ctrl->list); |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 136 | spin_unlock_bh(&ctrl->info_list_lock); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 137 | } |
| 138 | |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 139 | /* Compare and remove request */ |
Stephen Hemminger | 73d6ac6 | 2011-04-11 10:43:50 +0000 | [diff] [blame] | 140 | static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl, |
| 141 | struct cfctrl_request_info *req) |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 142 | { |
Sjur Braendeland | 7aecf49 | 2010-05-21 02:16:08 +0000 | [diff] [blame] | 143 | struct cfctrl_request_info *p, *tmp, *first; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 144 | |
Sjur Braendeland | 7aecf49 | 2010-05-21 02:16:08 +0000 | [diff] [blame] | 145 | first = list_first_entry(&ctrl->list, struct cfctrl_request_info, list); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 146 | |
Sjur Braendeland | 7aecf49 | 2010-05-21 02:16:08 +0000 | [diff] [blame] | 147 | list_for_each_entry_safe(p, tmp, &ctrl->list, list) { |
| 148 | if (cfctrl_req_eq(req, p)) { |
| 149 | if (p != first) |
Joe Perches | b31fa5b | 2010-09-05 21:31:11 +0000 | [diff] [blame] | 150 | pr_warn("Requests are not received in order\n"); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 151 | |
Sjur Braendeland | 7aecf49 | 2010-05-21 02:16:08 +0000 | [diff] [blame] | 152 | atomic_set(&ctrl->rsp_seq_no, |
| 153 | p->sequence_no); |
| 154 | list_del(&p->list); |
| 155 | goto out; |
| 156 | } |
| 157 | } |
| 158 | p = NULL; |
| 159 | out: |
Sjur Braendeland | 7aecf49 | 2010-05-21 02:16:08 +0000 | [diff] [blame] | 160 | return p; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | struct cfctrl_rsp *cfctrl_get_respfuncs(struct cflayer *layer) |
| 164 | { |
| 165 | struct cfctrl *this = container_obj(layer); |
| 166 | return &this->res; |
| 167 | } |
| 168 | |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 169 | static void init_info(struct caif_payload_info *info, struct cfctrl *cfctrl) |
| 170 | { |
| 171 | info->hdr_len = 0; |
| 172 | info->channel_id = cfctrl->serv.layer.id; |
| 173 | info->dev_info = &cfctrl->serv.dev_info; |
| 174 | } |
| 175 | |
| 176 | void cfctrl_enum_req(struct cflayer *layer, u8 physlinkid) |
| 177 | { |
Kim Lilliestierna XX | f315fd3 | 2012-06-25 07:49:35 +0000 | [diff] [blame] | 178 | struct cfpkt *pkt; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 179 | struct cfctrl *cfctrl = container_obj(layer); |
sjur.brandeland@stericsson.com | 0e5a117 | 2011-05-22 11:18:50 +0000 | [diff] [blame] | 180 | struct cflayer *dn = cfctrl->serv.layer.dn; |
Kim Lilliestierna XX | f315fd3 | 2012-06-25 07:49:35 +0000 | [diff] [blame] | 181 | |
sjur.brandeland@stericsson.com | 0e5a117 | 2011-05-22 11:18:50 +0000 | [diff] [blame] | 182 | if (!dn) { |
| 183 | pr_debug("not able to send enum request\n"); |
| 184 | return; |
| 185 | } |
Kim Lilliestierna XX | f315fd3 | 2012-06-25 07:49:35 +0000 | [diff] [blame] | 186 | pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN); |
| 187 | if (!pkt) |
| 188 | return; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 189 | caif_assert(offsetof(struct cfctrl, serv.layer) == 0); |
| 190 | init_info(cfpkt_info(pkt), cfctrl); |
| 191 | cfpkt_info(pkt)->dev_info->id = physlinkid; |
| 192 | cfctrl->serv.dev_info.id = physlinkid; |
| 193 | cfpkt_addbdy(pkt, CFCTRL_CMD_ENUM); |
| 194 | cfpkt_addbdy(pkt, physlinkid); |
Dmitry Tarnyagin | 4476481 | 2012-04-12 08:27:24 +0000 | [diff] [blame] | 195 | cfpkt_set_prio(pkt, TC_PRIO_CONTROL); |
sjur.brandeland@stericsson.com | 0e5a117 | 2011-05-22 11:18:50 +0000 | [diff] [blame] | 196 | dn->transmit(dn, pkt); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 197 | } |
| 198 | |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 199 | int cfctrl_linkup_request(struct cflayer *layer, |
Silviu-Mihai Popescu | 3bffc47 | 2013-03-06 19:39:57 +0000 | [diff] [blame] | 200 | struct cfctrl_link_param *param, |
| 201 | struct cflayer *user_layer) |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 202 | { |
| 203 | struct cfctrl *cfctrl = container_obj(layer); |
| 204 | u32 tmp32; |
| 205 | u16 tmp16; |
| 206 | u8 tmp8; |
| 207 | struct cfctrl_request_info *req; |
| 208 | int ret; |
| 209 | char utility_name[16]; |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 210 | struct cfpkt *pkt; |
sjur.brandeland@stericsson.com | 0e5a117 | 2011-05-22 11:18:50 +0000 | [diff] [blame] | 211 | struct cflayer *dn = cfctrl->serv.layer.dn; |
| 212 | |
| 213 | if (!dn) { |
| 214 | pr_debug("not able to send linkup request\n"); |
| 215 | return -ENODEV; |
| 216 | } |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 217 | |
| 218 | if (cfctrl_cancel_req(layer, user_layer) > 0) { |
| 219 | /* Slight Paranoia, check if already connecting */ |
| 220 | pr_err("Duplicate connect request for same client\n"); |
| 221 | WARN_ON(1); |
| 222 | return -EALREADY; |
| 223 | } |
| 224 | |
| 225 | pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN); |
Joe Perches | 7ac2ed0 | 2011-08-25 13:22:24 +0000 | [diff] [blame] | 226 | if (!pkt) |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 227 | return -ENOMEM; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 228 | cfpkt_addbdy(pkt, CFCTRL_CMD_LINK_SETUP); |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 229 | cfpkt_addbdy(pkt, (param->chtype << 4) | param->linktype); |
| 230 | cfpkt_addbdy(pkt, (param->priority << 3) | param->phyid); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 231 | cfpkt_addbdy(pkt, param->endpoint & 0x03); |
| 232 | |
| 233 | switch (param->linktype) { |
| 234 | case CFCTRL_SRV_VEI: |
| 235 | break; |
| 236 | case CFCTRL_SRV_VIDEO: |
| 237 | cfpkt_addbdy(pkt, (u8) param->u.video.connid); |
| 238 | break; |
| 239 | case CFCTRL_SRV_DBG: |
| 240 | break; |
| 241 | case CFCTRL_SRV_DATAGRAM: |
| 242 | tmp32 = cpu_to_le32(param->u.datagram.connid); |
| 243 | cfpkt_add_body(pkt, &tmp32, 4); |
| 244 | break; |
| 245 | case CFCTRL_SRV_RFM: |
| 246 | /* Construct a frame, convert DatagramConnectionID to network |
| 247 | * format long and copy it out... |
| 248 | */ |
| 249 | tmp32 = cpu_to_le32(param->u.rfm.connid); |
| 250 | cfpkt_add_body(pkt, &tmp32, 4); |
| 251 | /* Add volume name, including zero termination... */ |
| 252 | cfpkt_add_body(pkt, param->u.rfm.volume, |
| 253 | strlen(param->u.rfm.volume) + 1); |
| 254 | break; |
| 255 | case CFCTRL_SRV_UTIL: |
| 256 | tmp16 = cpu_to_le16(param->u.utility.fifosize_kb); |
| 257 | cfpkt_add_body(pkt, &tmp16, 2); |
| 258 | tmp16 = cpu_to_le16(param->u.utility.fifosize_bufs); |
| 259 | cfpkt_add_body(pkt, &tmp16, 2); |
| 260 | memset(utility_name, 0, sizeof(utility_name)); |
| 261 | strncpy(utility_name, param->u.utility.name, |
| 262 | UTILITY_NAME_LENGTH - 1); |
| 263 | cfpkt_add_body(pkt, utility_name, UTILITY_NAME_LENGTH); |
| 264 | tmp8 = param->u.utility.paramlen; |
| 265 | cfpkt_add_body(pkt, &tmp8, 1); |
| 266 | cfpkt_add_body(pkt, param->u.utility.params, |
| 267 | param->u.utility.paramlen); |
| 268 | break; |
| 269 | default: |
Joe Perches | b31fa5b | 2010-09-05 21:31:11 +0000 | [diff] [blame] | 270 | pr_warn("Request setup of bad link type = %d\n", |
| 271 | param->linktype); |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 272 | return -EINVAL; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 273 | } |
Julia Lawall | 49afa55 | 2010-05-13 10:03:32 +0000 | [diff] [blame] | 274 | req = kzalloc(sizeof(*req), GFP_KERNEL); |
Joe Perches | 7ac2ed0 | 2011-08-25 13:22:24 +0000 | [diff] [blame] | 275 | if (!req) |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 276 | return -ENOMEM; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 277 | req->client_layer = user_layer; |
| 278 | req->cmd = CFCTRL_CMD_LINK_SETUP; |
| 279 | req->param = *param; |
| 280 | cfctrl_insert_req(cfctrl, req); |
| 281 | init_info(cfpkt_info(pkt), cfctrl); |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 282 | /* |
| 283 | * NOTE:Always send linkup and linkdown request on the same |
| 284 | * device as the payload. Otherwise old queued up payload |
| 285 | * might arrive with the newly allocated channel ID. |
| 286 | */ |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 287 | cfpkt_info(pkt)->dev_info->id = param->phyid; |
Dmitry Tarnyagin | 4476481 | 2012-04-12 08:27:24 +0000 | [diff] [blame] | 288 | cfpkt_set_prio(pkt, TC_PRIO_CONTROL); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 289 | ret = |
sjur.brandeland@stericsson.com | 0e5a117 | 2011-05-22 11:18:50 +0000 | [diff] [blame] | 290 | dn->transmit(dn, pkt); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 291 | if (ret < 0) { |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 292 | int count; |
| 293 | |
| 294 | count = cfctrl_cancel_req(&cfctrl->serv.layer, |
| 295 | user_layer); |
Dave Jones | 0c1db73 | 2013-09-05 00:11:19 -0400 | [diff] [blame] | 296 | if (count != 1) { |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 297 | pr_err("Could not remove request (%d)", count); |
| 298 | return -ENODEV; |
Dave Jones | 0c1db73 | 2013-09-05 00:11:19 -0400 | [diff] [blame] | 299 | } |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 300 | } |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 301 | return 0; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | int cfctrl_linkdown_req(struct cflayer *layer, u8 channelid, |
Silviu-Mihai Popescu | 3bffc47 | 2013-03-06 19:39:57 +0000 | [diff] [blame] | 305 | struct cflayer *client) |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 306 | { |
| 307 | int ret; |
Kim Lilliestierna XX | f315fd3 | 2012-06-25 07:49:35 +0000 | [diff] [blame] | 308 | struct cfpkt *pkt; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 309 | struct cfctrl *cfctrl = container_obj(layer); |
sjur.brandeland@stericsson.com | 0e5a117 | 2011-05-22 11:18:50 +0000 | [diff] [blame] | 310 | struct cflayer *dn = cfctrl->serv.layer.dn; |
| 311 | |
sjur.brandeland@stericsson.com | 0e5a117 | 2011-05-22 11:18:50 +0000 | [diff] [blame] | 312 | if (!dn) { |
| 313 | pr_debug("not able to send link-down request\n"); |
| 314 | return -ENODEV; |
| 315 | } |
Kim Lilliestierna XX | f315fd3 | 2012-06-25 07:49:35 +0000 | [diff] [blame] | 316 | pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN); |
| 317 | if (!pkt) |
| 318 | return -ENOMEM; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 319 | cfpkt_addbdy(pkt, CFCTRL_CMD_LINK_DESTROY); |
| 320 | cfpkt_addbdy(pkt, channelid); |
| 321 | init_info(cfpkt_info(pkt), cfctrl); |
Dmitry Tarnyagin | 4476481 | 2012-04-12 08:27:24 +0000 | [diff] [blame] | 322 | cfpkt_set_prio(pkt, TC_PRIO_CONTROL); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 323 | ret = |
sjur.brandeland@stericsson.com | 0e5a117 | 2011-05-22 11:18:50 +0000 | [diff] [blame] | 324 | dn->transmit(dn, pkt); |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 325 | #ifndef CAIF_NO_LOOP |
| 326 | cfctrl->loop_linkused[channelid] = 0; |
| 327 | #endif |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 328 | return ret; |
| 329 | } |
| 330 | |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 331 | int cfctrl_cancel_req(struct cflayer *layr, struct cflayer *adap_layer) |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 332 | { |
Sjur Braendeland | 7aecf49 | 2010-05-21 02:16:08 +0000 | [diff] [blame] | 333 | struct cfctrl_request_info *p, *tmp; |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 334 | struct cfctrl *ctrl = container_obj(layr); |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 335 | int found = 0; |
| 336 | spin_lock_bh(&ctrl->info_list_lock); |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 337 | |
Sjur Braendeland | 7aecf49 | 2010-05-21 02:16:08 +0000 | [diff] [blame] | 338 | list_for_each_entry_safe(p, tmp, &ctrl->list, list) { |
| 339 | if (p->client_layer == adap_layer) { |
Sjur Braendeland | 7aecf49 | 2010-05-21 02:16:08 +0000 | [diff] [blame] | 340 | list_del(&p->list); |
| 341 | kfree(p); |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 342 | found++; |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 343 | } |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 344 | } |
| 345 | |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 346 | spin_unlock_bh(&ctrl->info_list_lock); |
| 347 | return found; |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 348 | } |
| 349 | |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 350 | static int cfctrl_recv(struct cflayer *layer, struct cfpkt *pkt) |
| 351 | { |
| 352 | u8 cmdrsp; |
| 353 | u8 cmd; |
| 354 | int ret = -1; |
| 355 | u16 tmp16; |
| 356 | u8 len; |
| 357 | u8 param[255]; |
| 358 | u8 linkid; |
| 359 | struct cfctrl *cfctrl = container_obj(layer); |
| 360 | struct cfctrl_request_info rsp, *req; |
| 361 | |
| 362 | |
| 363 | cfpkt_extr_head(pkt, &cmdrsp, 1); |
| 364 | cmd = cmdrsp & CFCTRL_CMD_MASK; |
| 365 | if (cmd != CFCTRL_CMD_LINK_ERR |
sjur.brandeland@stericsson.com | 96796ea | 2011-05-22 11:18:52 +0000 | [diff] [blame] | 366 | && CFCTRL_RSP_BIT != (CFCTRL_RSP_BIT & cmdrsp) |
| 367 | && CFCTRL_ERR_BIT != (CFCTRL_ERR_BIT & cmdrsp)) { |
Sjur Braendeland | 2aa40ae | 2010-06-17 06:55:40 +0000 | [diff] [blame] | 368 | if (handle_loop(cfctrl, cmd, pkt) != 0) |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 369 | cmdrsp |= CFCTRL_ERR_BIT; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | switch (cmd) { |
| 373 | case CFCTRL_CMD_LINK_SETUP: |
| 374 | { |
| 375 | enum cfctrl_srv serv; |
| 376 | enum cfctrl_srv servtype; |
| 377 | u8 endpoint; |
| 378 | u8 physlinkid; |
| 379 | u8 prio; |
| 380 | u8 tmp; |
| 381 | u32 tmp32; |
| 382 | u8 *cp; |
| 383 | int i; |
| 384 | struct cfctrl_link_param linkparam; |
| 385 | memset(&linkparam, 0, sizeof(linkparam)); |
| 386 | |
| 387 | cfpkt_extr_head(pkt, &tmp, 1); |
| 388 | |
| 389 | serv = tmp & CFCTRL_SRV_MASK; |
| 390 | linkparam.linktype = serv; |
| 391 | |
| 392 | servtype = tmp >> 4; |
| 393 | linkparam.chtype = servtype; |
| 394 | |
| 395 | cfpkt_extr_head(pkt, &tmp, 1); |
| 396 | physlinkid = tmp & 0x07; |
| 397 | prio = tmp >> 3; |
| 398 | |
| 399 | linkparam.priority = prio; |
| 400 | linkparam.phyid = physlinkid; |
| 401 | cfpkt_extr_head(pkt, &endpoint, 1); |
| 402 | linkparam.endpoint = endpoint & 0x03; |
| 403 | |
| 404 | switch (serv) { |
| 405 | case CFCTRL_SRV_VEI: |
| 406 | case CFCTRL_SRV_DBG: |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 407 | if (CFCTRL_ERR_BIT & cmdrsp) |
| 408 | break; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 409 | /* Link ID */ |
| 410 | cfpkt_extr_head(pkt, &linkid, 1); |
| 411 | break; |
| 412 | case CFCTRL_SRV_VIDEO: |
| 413 | cfpkt_extr_head(pkt, &tmp, 1); |
| 414 | linkparam.u.video.connid = tmp; |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 415 | if (CFCTRL_ERR_BIT & cmdrsp) |
| 416 | break; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 417 | /* Link ID */ |
| 418 | cfpkt_extr_head(pkt, &linkid, 1); |
| 419 | break; |
| 420 | |
| 421 | case CFCTRL_SRV_DATAGRAM: |
| 422 | cfpkt_extr_head(pkt, &tmp32, 4); |
| 423 | linkparam.u.datagram.connid = |
| 424 | le32_to_cpu(tmp32); |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 425 | if (CFCTRL_ERR_BIT & cmdrsp) |
| 426 | break; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 427 | /* Link ID */ |
| 428 | cfpkt_extr_head(pkt, &linkid, 1); |
| 429 | break; |
| 430 | case CFCTRL_SRV_RFM: |
| 431 | /* Construct a frame, convert |
| 432 | * DatagramConnectionID |
| 433 | * to network format long and copy it out... |
| 434 | */ |
| 435 | cfpkt_extr_head(pkt, &tmp32, 4); |
| 436 | linkparam.u.rfm.connid = |
| 437 | le32_to_cpu(tmp32); |
| 438 | cp = (u8 *) linkparam.u.rfm.volume; |
| 439 | for (cfpkt_extr_head(pkt, &tmp, 1); |
| 440 | cfpkt_more(pkt) && tmp != '\0'; |
| 441 | cfpkt_extr_head(pkt, &tmp, 1)) |
| 442 | *cp++ = tmp; |
| 443 | *cp = '\0'; |
| 444 | |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 445 | if (CFCTRL_ERR_BIT & cmdrsp) |
| 446 | break; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 447 | /* Link ID */ |
| 448 | cfpkt_extr_head(pkt, &linkid, 1); |
| 449 | |
| 450 | break; |
| 451 | case CFCTRL_SRV_UTIL: |
| 452 | /* Construct a frame, convert |
| 453 | * DatagramConnectionID |
| 454 | * to network format long and copy it out... |
| 455 | */ |
| 456 | /* Fifosize KB */ |
| 457 | cfpkt_extr_head(pkt, &tmp16, 2); |
| 458 | linkparam.u.utility.fifosize_kb = |
| 459 | le16_to_cpu(tmp16); |
| 460 | /* Fifosize bufs */ |
| 461 | cfpkt_extr_head(pkt, &tmp16, 2); |
| 462 | linkparam.u.utility.fifosize_bufs = |
| 463 | le16_to_cpu(tmp16); |
| 464 | /* name */ |
| 465 | cp = (u8 *) linkparam.u.utility.name; |
| 466 | caif_assert(sizeof(linkparam.u.utility.name) |
| 467 | >= UTILITY_NAME_LENGTH); |
| 468 | for (i = 0; |
| 469 | i < UTILITY_NAME_LENGTH |
| 470 | && cfpkt_more(pkt); i++) { |
| 471 | cfpkt_extr_head(pkt, &tmp, 1); |
| 472 | *cp++ = tmp; |
| 473 | } |
| 474 | /* Length */ |
| 475 | cfpkt_extr_head(pkt, &len, 1); |
| 476 | linkparam.u.utility.paramlen = len; |
| 477 | /* Param Data */ |
| 478 | cp = linkparam.u.utility.params; |
| 479 | while (cfpkt_more(pkt) && len--) { |
| 480 | cfpkt_extr_head(pkt, &tmp, 1); |
| 481 | *cp++ = tmp; |
| 482 | } |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 483 | if (CFCTRL_ERR_BIT & cmdrsp) |
| 484 | break; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 485 | /* Link ID */ |
| 486 | cfpkt_extr_head(pkt, &linkid, 1); |
| 487 | /* Length */ |
| 488 | cfpkt_extr_head(pkt, &len, 1); |
| 489 | /* Param Data */ |
| 490 | cfpkt_extr_head(pkt, ¶m, len); |
| 491 | break; |
| 492 | default: |
sjur.brandeland@stericsson.com | 0e5a117 | 2011-05-22 11:18:50 +0000 | [diff] [blame] | 493 | pr_warn("Request setup, invalid type (%d)\n", |
Joe Perches | b31fa5b | 2010-09-05 21:31:11 +0000 | [diff] [blame] | 494 | serv); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 495 | goto error; |
| 496 | } |
| 497 | |
| 498 | rsp.cmd = cmd; |
| 499 | rsp.param = linkparam; |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 500 | spin_lock_bh(&cfctrl->info_list_lock); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 501 | req = cfctrl_remove_req(cfctrl, &rsp); |
| 502 | |
| 503 | if (CFCTRL_ERR_BIT == (CFCTRL_ERR_BIT & cmdrsp) || |
| 504 | cfpkt_erroneous(pkt)) { |
sjur.brandeland@stericsson.com | 0e5a117 | 2011-05-22 11:18:50 +0000 | [diff] [blame] | 505 | pr_err("Invalid O/E bit or parse error " |
| 506 | "on CAIF control channel\n"); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 507 | cfctrl->res.reject_rsp(cfctrl->serv.layer.up, |
| 508 | 0, |
| 509 | req ? req->client_layer |
| 510 | : NULL); |
| 511 | } else { |
| 512 | cfctrl->res.linksetup_rsp(cfctrl->serv. |
| 513 | layer.up, linkid, |
| 514 | serv, physlinkid, |
| 515 | req ? req-> |
| 516 | client_layer : NULL); |
| 517 | } |
| 518 | |
Sachin Kamat | 973b1b9 | 2012-11-20 00:53:58 +0000 | [diff] [blame] | 519 | kfree(req); |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 520 | |
| 521 | spin_unlock_bh(&cfctrl->info_list_lock); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 522 | } |
| 523 | break; |
| 524 | case CFCTRL_CMD_LINK_DESTROY: |
| 525 | cfpkt_extr_head(pkt, &linkid, 1); |
Sjur Braendeland | 8d545c8 | 2010-04-28 08:54:37 +0000 | [diff] [blame] | 526 | cfctrl->res.linkdestroy_rsp(cfctrl->serv.layer.up, linkid); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 527 | break; |
| 528 | case CFCTRL_CMD_LINK_ERR: |
Joe Perches | b31fa5b | 2010-09-05 21:31:11 +0000 | [diff] [blame] | 529 | pr_err("Frame Error Indication received\n"); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 530 | cfctrl->res.linkerror_ind(); |
| 531 | break; |
| 532 | case CFCTRL_CMD_ENUM: |
| 533 | cfctrl->res.enum_rsp(); |
| 534 | break; |
| 535 | case CFCTRL_CMD_SLEEP: |
| 536 | cfctrl->res.sleep_rsp(); |
| 537 | break; |
| 538 | case CFCTRL_CMD_WAKE: |
| 539 | cfctrl->res.wake_rsp(); |
| 540 | break; |
| 541 | case CFCTRL_CMD_LINK_RECONF: |
| 542 | cfctrl->res.restart_rsp(); |
| 543 | break; |
| 544 | case CFCTRL_CMD_RADIO_SET: |
| 545 | cfctrl->res.radioset_rsp(); |
| 546 | break; |
| 547 | default: |
Joe Perches | b31fa5b | 2010-09-05 21:31:11 +0000 | [diff] [blame] | 548 | pr_err("Unrecognized Control Frame\n"); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 549 | goto error; |
| 550 | break; |
| 551 | } |
| 552 | ret = 0; |
| 553 | error: |
| 554 | cfpkt_destroy(pkt); |
| 555 | return ret; |
| 556 | } |
| 557 | |
| 558 | static void cfctrl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl, |
Silviu-Mihai Popescu | 3bffc47 | 2013-03-06 19:39:57 +0000 | [diff] [blame] | 559 | int phyid) |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 560 | { |
| 561 | struct cfctrl *this = container_obj(layr); |
| 562 | switch (ctrl) { |
| 563 | case _CAIF_CTRLCMD_PHYIF_FLOW_OFF_IND: |
| 564 | case CAIF_CTRLCMD_FLOW_OFF_IND: |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 565 | spin_lock_bh(&this->info_list_lock); |
sjur.brandeland@stericsson.com | 0e5a117 | 2011-05-22 11:18:50 +0000 | [diff] [blame] | 566 | if (!list_empty(&this->list)) |
Joe Perches | b31fa5b | 2010-09-05 21:31:11 +0000 | [diff] [blame] | 567 | pr_debug("Received flow off in control layer\n"); |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 568 | spin_unlock_bh(&this->info_list_lock); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 569 | break; |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 570 | case _CAIF_CTRLCMD_PHYIF_DOWN_IND: { |
| 571 | struct cfctrl_request_info *p, *tmp; |
| 572 | |
| 573 | /* Find all connect request and report failure */ |
| 574 | spin_lock_bh(&this->info_list_lock); |
| 575 | list_for_each_entry_safe(p, tmp, &this->list, list) { |
| 576 | if (p->param.phyid == phyid) { |
| 577 | list_del(&p->list); |
| 578 | p->client_layer->ctrlcmd(p->client_layer, |
| 579 | CAIF_CTRLCMD_INIT_FAIL_RSP, |
| 580 | phyid); |
| 581 | kfree(p); |
| 582 | } |
| 583 | } |
| 584 | spin_unlock_bh(&this->info_list_lock); |
| 585 | break; |
| 586 | } |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 587 | default: |
| 588 | break; |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | #ifndef CAIF_NO_LOOP |
| 593 | static int handle_loop(struct cfctrl *ctrl, int cmd, struct cfpkt *pkt) |
| 594 | { |
| 595 | static int last_linkid; |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 596 | static int dec; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 597 | u8 linkid, linktype, tmp; |
| 598 | switch (cmd) { |
| 599 | case CFCTRL_CMD_LINK_SETUP: |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 600 | spin_lock_bh(&ctrl->loop_linkid_lock); |
| 601 | if (!dec) { |
sjur.brandeland@stericsson.com | 96796ea | 2011-05-22 11:18:52 +0000 | [diff] [blame] | 602 | for (linkid = last_linkid + 1; linkid < 254; linkid++) |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 603 | if (!ctrl->loop_linkused[linkid]) |
| 604 | goto found; |
| 605 | } |
| 606 | dec = 1; |
sjur.brandeland@stericsson.com | 96796ea | 2011-05-22 11:18:52 +0000 | [diff] [blame] | 607 | for (linkid = last_linkid - 1; linkid > 1; linkid--) |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 608 | if (!ctrl->loop_linkused[linkid]) |
| 609 | goto found; |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 610 | spin_unlock_bh(&ctrl->loop_linkid_lock); |
sjur.brandeland@stericsson.com | 96796ea | 2011-05-22 11:18:52 +0000 | [diff] [blame] | 611 | return -1; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 612 | found: |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 613 | if (linkid < 10) |
| 614 | dec = 0; |
| 615 | |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 616 | if (!ctrl->loop_linkused[linkid]) |
| 617 | ctrl->loop_linkused[linkid] = 1; |
| 618 | |
| 619 | last_linkid = linkid; |
| 620 | |
| 621 | cfpkt_add_trail(pkt, &linkid, 1); |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 622 | spin_unlock_bh(&ctrl->loop_linkid_lock); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 623 | cfpkt_peek_head(pkt, &linktype, 1); |
| 624 | if (linktype == CFCTRL_SRV_UTIL) { |
| 625 | tmp = 0x01; |
| 626 | cfpkt_add_trail(pkt, &tmp, 1); |
| 627 | cfpkt_add_trail(pkt, &tmp, 1); |
| 628 | } |
| 629 | break; |
| 630 | |
| 631 | case CFCTRL_CMD_LINK_DESTROY: |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 632 | spin_lock_bh(&ctrl->loop_linkid_lock); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 633 | cfpkt_peek_head(pkt, &linkid, 1); |
| 634 | ctrl->loop_linkused[linkid] = 0; |
sjur.brandeland@stericsson.com | c85c295 | 2011-05-13 02:44:06 +0000 | [diff] [blame] | 635 | spin_unlock_bh(&ctrl->loop_linkid_lock); |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 636 | break; |
| 637 | default: |
| 638 | break; |
| 639 | } |
Sjur Braendeland | 2aa40ae | 2010-06-17 06:55:40 +0000 | [diff] [blame] | 640 | return 0; |
Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +0000 | [diff] [blame] | 641 | } |
| 642 | #endif |