Lines Matching refs:fdev
59 static struct mlx5_fpga_trans_priv *find_tid(struct mlx5_fpga_device *fdev, in find_tid() argument
63 mlx5_fpga_warn(fdev, "Unexpected transaction ID %u\n", tid); in find_tid()
66 return &fdev->trans->transactions[tid]; in find_tid()
69 static struct mlx5_fpga_trans_priv *alloc_tid(struct mlx5_fpga_device *fdev) in alloc_tid() argument
74 spin_lock_irqsave(&fdev->trans->lock, flags); in alloc_tid()
76 if (list_empty(&fdev->trans->free_queue)) { in alloc_tid()
77 mlx5_fpga_dbg(fdev, "No free transaction ID available\n"); in alloc_tid()
82 ret = list_first_entry(&fdev->trans->free_queue, in alloc_tid()
88 spin_unlock_irqrestore(&fdev->trans->lock, flags); in alloc_tid()
92 static void free_tid(struct mlx5_fpga_device *fdev, in free_tid() argument
97 spin_lock_irqsave(&fdev->trans->lock, flags); in free_tid()
98 list_add_tail(&trans_priv->list_item, &fdev->trans->free_queue); in free_tid()
99 spin_unlock_irqrestore(&fdev->trans->lock, flags); in free_tid()
102 static void trans_complete(struct mlx5_fpga_device *fdev, in trans_complete() argument
108 mlx5_fpga_dbg(fdev, "Transaction %u is complete with status %u\n", in trans_complete()
111 spin_lock_irqsave(&fdev->trans->lock, flags); in trans_complete()
114 spin_unlock_irqrestore(&fdev->trans->lock, flags); in trans_complete()
117 free_tid(fdev, trans_priv); in trans_complete()
124 struct mlx5_fpga_device *fdev, in trans_send_complete() argument
131 mlx5_fpga_dbg(fdev, "send complete tid %u. Status: %u\n", in trans_send_complete()
134 trans_complete(fdev, trans_priv, status); in trans_send_complete()
138 spin_lock_irqsave(&fdev->trans->lock, flags); in trans_send_complete()
141 spin_unlock_irqrestore(&fdev->trans->lock, flags); in trans_send_complete()
144 static int trans_validate(struct mlx5_fpga_device *fdev, u64 addr, size_t size) in trans_validate() argument
147 mlx5_fpga_warn(fdev, "Cannot access %zu bytes at once. Max is %u\n", in trans_validate()
152 mlx5_fpga_warn(fdev, "Cannot access %zu bytes. Must be full dwords\n", in trans_validate()
157 mlx5_fpga_warn(fdev, "Cannot access %zu bytes. Empty transaction not allowed\n", in trans_validate()
162 mlx5_fpga_warn(fdev, "Cannot access %zu bytes at unaligned address %jx\n", in trans_validate()
168 mlx5_fpga_warn(fdev, "Cannot access %zu bytes at address %jx. Crosses page boundary\n", in trans_validate()
172 if (addr < mlx5_fpga_ddr_base_get(fdev)) { in trans_validate()
174 …mlx5_fpga_warn(fdev, "Cannot access %zu bytes at cr-space address %jx. Must access a single dword\… in trans_validate()
190 mlx5_fpga_warn(conn->fdev, "Transaction must have a completion callback\n"); in mlx5_fpga_trans_exec()
195 err = trans_validate(conn->fdev, trans->addr, trans->size); in mlx5_fpga_trans_exec()
199 trans_priv = alloc_tid(conn->fdev); in mlx5_fpga_trans_exec()
229 err = mlx5_fpga_conn_send(conn->fdev->shell_conn, &trans_priv->buf); in mlx5_fpga_trans_exec()
238 free_tid(conn->fdev, trans_priv); in mlx5_fpga_trans_exec()
245 struct mlx5_fpga_device *fdev = cb_arg; in mlx5_fpga_trans_recv() local
251 mlx5_fpga_dbg(fdev, "Rx QP message on core conn; %u bytes\n", in mlx5_fpga_trans_recv()
255 mlx5_fpga_warn(fdev, "Short message %u bytes from device\n", in mlx5_fpga_trans_recv()
262 trans_priv = find_tid(fdev, tid); in mlx5_fpga_trans_recv()
270 mlx5_fpga_warn(fdev, "Wrong answer type %u to a %u transaction\n", in mlx5_fpga_trans_recv()
276 mlx5_fpga_warn(fdev, "Incorrect transaction payload length %zu expected %zu\n", in mlx5_fpga_trans_recv()
287 mlx5_fpga_warn(fdev, "Wrong answer type %u to a %u transaction\n", in mlx5_fpga_trans_recv()
294 mlx5_fpga_warn(fdev, "Unexpected message type %u len %u from device\n", in mlx5_fpga_trans_recv()
301 trans_complete(fdev, trans_priv, status); in mlx5_fpga_trans_recv()
306 int mlx5_fpga_trans_device_init(struct mlx5_fpga_device *fdev) in mlx5_fpga_trans_device_init() argument
311 fdev->trans = kzalloc(sizeof(*fdev->trans), GFP_KERNEL); in mlx5_fpga_trans_device_init()
312 if (!fdev->trans) { in mlx5_fpga_trans_device_init()
317 INIT_LIST_HEAD(&fdev->trans->free_queue); in mlx5_fpga_trans_device_init()
318 for (tid = 0; tid < ARRAY_SIZE(fdev->trans->transactions); tid++) { in mlx5_fpga_trans_device_init()
319 fdev->trans->transactions[tid].tid = tid; in mlx5_fpga_trans_device_init()
320 list_add_tail(&fdev->trans->transactions[tid].list_item, in mlx5_fpga_trans_device_init()
321 &fdev->trans->free_queue); in mlx5_fpga_trans_device_init()
324 spin_lock_init(&fdev->trans->lock); in mlx5_fpga_trans_device_init()
330 void mlx5_fpga_trans_device_cleanup(struct mlx5_fpga_device *fdev) in mlx5_fpga_trans_device_cleanup() argument
332 kfree(fdev->trans); in mlx5_fpga_trans_device_cleanup()