Lines Matching refs:pkg

149 static int check_header(struct ctl_pkg *pkg, u32 len, enum tb_cfg_pkg_type type,  in check_header()  argument
152 struct tb_cfg_header *header = pkg->buffer; in check_header()
155 if (WARN(len != pkg->frame.size, in check_header()
157 len, pkg->frame.size)) in check_header()
159 if (WARN(type != pkg->frame.eof, "wrong eof (expected %#x, got %#x)\n", in check_header()
160 type, pkg->frame.eof)) in check_header()
162 if (WARN(pkg->frame.sof, "wrong sof (expected 0x0, got %#x)\n", in check_header()
163 pkg->frame.sof)) in check_header()
203 struct cfg_error_pkg *pkg = response->buffer; in decode_error() local
205 res.response_route = get_route(pkg->header); in decode_error()
207 res.err = check_header(response, sizeof(*pkg), TB_CFG_PKG_ERROR, in decode_error()
208 get_route(pkg->header)); in decode_error()
212 WARN(pkg->zero1, "pkg->zero1 is %#x\n", pkg->zero1); in decode_error()
213 WARN(pkg->zero2, "pkg->zero1 is %#x\n", pkg->zero1); in decode_error()
214 WARN(pkg->zero3, "pkg->zero1 is %#x\n", pkg->zero1); in decode_error()
216 res.tb_error = pkg->error; in decode_error()
217 res.response_port = pkg->port; in decode_error()
222 static struct tb_cfg_result parse_header(struct ctl_pkg *pkg, u32 len, in parse_header() argument
225 struct tb_cfg_header *header = pkg->buffer; in parse_header()
228 if (pkg->frame.eof == TB_CFG_PKG_ERROR) in parse_header()
229 return decode_error(pkg); in parse_header()
233 res.err = check_header(pkg, len, type, route); in parse_header()
295 static void tb_ctl_pkg_free(struct ctl_pkg *pkg) in tb_ctl_pkg_free() argument
297 if (pkg) { in tb_ctl_pkg_free()
298 dma_pool_free(pkg->ctl->frame_pool, in tb_ctl_pkg_free()
299 pkg->buffer, pkg->frame.buffer_phy); in tb_ctl_pkg_free()
300 kfree(pkg); in tb_ctl_pkg_free()
306 struct ctl_pkg *pkg = kzalloc(sizeof(*pkg), GFP_KERNEL); in tb_ctl_pkg_alloc() local
307 if (!pkg) in tb_ctl_pkg_alloc()
309 pkg->ctl = ctl; in tb_ctl_pkg_alloc()
310 pkg->buffer = dma_pool_alloc(ctl->frame_pool, GFP_KERNEL, in tb_ctl_pkg_alloc()
311 &pkg->frame.buffer_phy); in tb_ctl_pkg_alloc()
312 if (!pkg->buffer) { in tb_ctl_pkg_alloc()
313 kfree(pkg); in tb_ctl_pkg_alloc()
316 return pkg; in tb_ctl_pkg_alloc()
325 struct ctl_pkg *pkg = container_of(frame, typeof(*pkg), frame); in tb_ctl_tx_callback() local
326 tb_ctl_pkg_free(pkg); in tb_ctl_tx_callback()
340 struct ctl_pkg *pkg; in tb_ctl_tx() local
350 pkg = tb_ctl_pkg_alloc(ctl); in tb_ctl_tx()
351 if (!pkg) in tb_ctl_tx()
353 pkg->frame.callback = tb_ctl_tx_callback; in tb_ctl_tx()
354 pkg->frame.size = len + 4; in tb_ctl_tx()
355 pkg->frame.sof = type; in tb_ctl_tx()
356 pkg->frame.eof = type; in tb_ctl_tx()
357 cpu_to_be32_array(pkg->buffer, data, len / 4); in tb_ctl_tx()
358 *(__be32 *) (pkg->buffer + len) = tb_crc(pkg->buffer, len); in tb_ctl_tx()
360 res = ring_tx(ctl->tx, &pkg->frame); in tb_ctl_tx()
362 tb_ctl_pkg_free(pkg); in tb_ctl_tx()
372 struct cfg_event_pkg *pkg = response->buffer; in tb_ctl_handle_plug_event() local
373 u64 route = get_route(pkg->header); in tb_ctl_handle_plug_event()
375 if (check_header(response, sizeof(*pkg), TB_CFG_PKG_EVENT, route)) { in tb_ctl_handle_plug_event()
380 if (tb_cfg_error(ctl, route, pkg->port, TB_CFG_ERROR_ACK_PLUG_EVENT)) in tb_ctl_handle_plug_event()
382 route, pkg->port); in tb_ctl_handle_plug_event()
383 WARN(pkg->zero, "pkg->zero is %#x\n", pkg->zero); in tb_ctl_handle_plug_event()
384 ctl->callback(ctl->callback_data, route, pkg->port, pkg->unplug); in tb_ctl_handle_plug_event()
387 static void tb_ctl_rx_submit(struct ctl_pkg *pkg) in tb_ctl_rx_submit() argument
389 ring_rx(pkg->ctl->rx, &pkg->frame); /* in tb_ctl_rx_submit()
400 struct ctl_pkg *pkg = container_of(frame, typeof(*pkg), frame); in tb_ctl_rx_callback() local
409 tb_ctl_err(pkg->ctl, "RX: invalid size %#x, dropping packet\n", in tb_ctl_rx_callback()
415 if (*(__be32 *) (pkg->buffer + frame->size) in tb_ctl_rx_callback()
416 != tb_crc(pkg->buffer, frame->size)) { in tb_ctl_rx_callback()
417 tb_ctl_err(pkg->ctl, in tb_ctl_rx_callback()
421 be32_to_cpu_array(pkg->buffer, pkg->buffer, frame->size / 4); in tb_ctl_rx_callback()
424 tb_ctl_handle_plug_event(pkg->ctl, pkg); in tb_ctl_rx_callback()
427 if (!kfifo_put(&pkg->ctl->response_fifo, pkg)) { in tb_ctl_rx_callback()
428 tb_ctl_err(pkg->ctl, "RX: fifo is full\n"); in tb_ctl_rx_callback()
431 complete(&pkg->ctl->response_ready); in tb_ctl_rx_callback()
434 tb_ctl_rx_submit(pkg); in tb_ctl_rx_callback()
445 struct ctl_pkg *pkg; in tb_ctl_rx() local
452 if (!kfifo_get(&ctl->response_fifo, &pkg)) { in tb_ctl_rx()
457 res = parse_header(pkg, length, type, route); in tb_ctl_rx()
459 memcpy(buffer, pkg->buffer, length); in tb_ctl_rx()
460 tb_ctl_rx_submit(pkg); in tb_ctl_rx()
580 struct cfg_error_pkg pkg = { in tb_cfg_error() local
586 return tb_ctl_tx(ctl, &pkg, sizeof(pkg), TB_CFG_PKG_ERROR); in tb_cfg_error()