@@ -1168,6 +1168,38 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_QUERY)(
11681168 cmd_out , cmd_out_len );
11691169}
11701170
1171+ struct devx_async_event_queue {
1172+ spinlock_t lock ;
1173+ wait_queue_head_t poll_wait ;
1174+ struct list_head event_list ;
1175+ };
1176+
1177+ struct devx_async_cmd_event_file {
1178+ struct ib_uobject uobj ;
1179+ struct devx_async_event_queue ev_queue ;
1180+ };
1181+
1182+ static void devx_init_event_queue (struct devx_async_event_queue * ev_queue )
1183+ {
1184+ spin_lock_init (& ev_queue -> lock );
1185+ INIT_LIST_HEAD (& ev_queue -> event_list );
1186+ init_waitqueue_head (& ev_queue -> poll_wait );
1187+ }
1188+
1189+ static int UVERBS_HANDLER (MLX5_IB_METHOD_DEVX_ASYNC_CMD_FD_ALLOC )(
1190+ struct uverbs_attr_bundle * attrs )
1191+ {
1192+ struct devx_async_cmd_event_file * ev_file ;
1193+
1194+ struct ib_uobject * uobj = uverbs_attr_get_uobject (
1195+ attrs , MLX5_IB_ATTR_DEVX_ASYNC_CMD_FD_ALLOC_HANDLE );
1196+
1197+ ev_file = container_of (uobj , struct devx_async_cmd_event_file ,
1198+ uobj );
1199+ devx_init_event_queue (& ev_file -> ev_queue );
1200+ return 0 ;
1201+ }
1202+
11711203static int devx_umem_get (struct mlx5_ib_dev * dev , struct ib_ucontext * ucontext ,
11721204 struct uverbs_attr_bundle * attrs ,
11731205 struct devx_umem * obj )
@@ -1313,6 +1345,38 @@ static int devx_umem_cleanup(struct ib_uobject *uobject,
13131345 return 0 ;
13141346}
13151347
1348+ static ssize_t devx_async_cmd_event_read (struct file * filp , char __user * buf ,
1349+ size_t count , loff_t * pos )
1350+ {
1351+ return - EINVAL ;
1352+ }
1353+
1354+ static int devx_async_cmd_event_close (struct inode * inode , struct file * filp )
1355+ {
1356+ uverbs_close_fd (filp );
1357+ return 0 ;
1358+ }
1359+
1360+ static __poll_t devx_async_cmd_event_poll (struct file * filp ,
1361+ struct poll_table_struct * wait )
1362+ {
1363+ return 0 ;
1364+ }
1365+
1366+ const struct file_operations devx_async_cmd_event_fops = {
1367+ .owner = THIS_MODULE ,
1368+ .read = devx_async_cmd_event_read ,
1369+ .poll = devx_async_cmd_event_poll ,
1370+ .release = devx_async_cmd_event_close ,
1371+ .llseek = no_llseek ,
1372+ };
1373+
1374+ static int devx_hot_unplug_async_cmd_event_file (struct ib_uobject * uobj ,
1375+ enum rdma_remove_reason why )
1376+ {
1377+ return 0 ;
1378+ };
1379+
13161380DECLARE_UVERBS_NAMED_METHOD (
13171381 MLX5_IB_METHOD_DEVX_UMEM_REG ,
13181382 UVERBS_ATTR_IDR (MLX5_IB_ATTR_DEVX_UMEM_REG_HANDLE ,
@@ -1440,6 +1504,22 @@ DECLARE_UVERBS_NAMED_OBJECT(MLX5_IB_OBJECT_DEVX_UMEM,
14401504 & UVERBS_METHOD (MLX5_IB_METHOD_DEVX_UMEM_REG ),
14411505 & UVERBS_METHOD (MLX5_IB_METHOD_DEVX_UMEM_DEREG ));
14421506
1507+
1508+ DECLARE_UVERBS_NAMED_METHOD (
1509+ MLX5_IB_METHOD_DEVX_ASYNC_CMD_FD_ALLOC ,
1510+ UVERBS_ATTR_FD (MLX5_IB_ATTR_DEVX_ASYNC_CMD_FD_ALLOC_HANDLE ,
1511+ MLX5_IB_OBJECT_DEVX_ASYNC_CMD_FD ,
1512+ UVERBS_ACCESS_NEW ,
1513+ UA_MANDATORY ));
1514+
1515+ DECLARE_UVERBS_NAMED_OBJECT (
1516+ MLX5_IB_OBJECT_DEVX_ASYNC_CMD_FD ,
1517+ UVERBS_TYPE_ALLOC_FD (sizeof (struct devx_async_cmd_event_file ),
1518+ devx_hot_unplug_async_cmd_event_file ,
1519+ & devx_async_cmd_event_fops , "[devx_async_cmd]" ,
1520+ O_RDONLY ),
1521+ & UVERBS_METHOD (MLX5_IB_METHOD_DEVX_ASYNC_CMD_FD_ALLOC ));
1522+
14431523static bool devx_is_supported (struct ib_device * device )
14441524{
14451525 struct mlx5_ib_dev * dev = to_mdev (device );
@@ -1457,5 +1537,8 @@ const struct uapi_definition mlx5_ib_devx_defs[] = {
14571537 UAPI_DEF_CHAIN_OBJ_TREE_NAMED (
14581538 MLX5_IB_OBJECT_DEVX_UMEM ,
14591539 UAPI_DEF_IS_OBJ_SUPPORTED (devx_is_supported )),
1540+ UAPI_DEF_CHAIN_OBJ_TREE_NAMED (
1541+ MLX5_IB_OBJECT_DEVX_ASYNC_CMD_FD ,
1542+ UAPI_DEF_IS_OBJ_SUPPORTED (devx_is_supported )),
14601543 {},
14611544};
0 commit comments