@@ -318,6 +318,118 @@ int mlx5_modify_nic_vport_mac_list(struct mlx5_core_dev *dev,
318
318
}
319
319
EXPORT_SYMBOL_GPL (mlx5_modify_nic_vport_mac_list );
320
320
321
+ int mlx5_query_nic_vport_vlans (struct mlx5_core_dev * dev ,
322
+ u32 vport ,
323
+ u16 vlans [],
324
+ int * size )
325
+ {
326
+ u32 in [MLX5_ST_SZ_DW (query_nic_vport_context_in )];
327
+ void * nic_vport_ctx ;
328
+ int req_list_size ;
329
+ int max_list_size ;
330
+ int out_sz ;
331
+ void * out ;
332
+ int err ;
333
+ int i ;
334
+
335
+ req_list_size = * size ;
336
+ max_list_size = 1 << MLX5_CAP_GEN (dev , log_max_vlan_list );
337
+ if (req_list_size > max_list_size ) {
338
+ mlx5_core_warn (dev , "Requested list size (%d) > (%d) max list size\n" ,
339
+ req_list_size , max_list_size );
340
+ req_list_size = max_list_size ;
341
+ }
342
+
343
+ out_sz = MLX5_ST_SZ_BYTES (modify_nic_vport_context_in ) +
344
+ req_list_size * MLX5_ST_SZ_BYTES (vlan_layout );
345
+
346
+ memset (in , 0 , sizeof (in ));
347
+ out = kzalloc (out_sz , GFP_KERNEL );
348
+ if (!out )
349
+ return - ENOMEM ;
350
+
351
+ MLX5_SET (query_nic_vport_context_in , in , opcode ,
352
+ MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT );
353
+ MLX5_SET (query_nic_vport_context_in , in , allowed_list_type ,
354
+ MLX5_NVPRT_LIST_TYPE_VLAN );
355
+ MLX5_SET (query_nic_vport_context_in , in , vport_number , vport );
356
+
357
+ if (vport )
358
+ MLX5_SET (query_nic_vport_context_in , in , other_vport , 1 );
359
+
360
+ err = mlx5_cmd_exec_check_status (dev , in , sizeof (in ), out , out_sz );
361
+ if (err )
362
+ goto out ;
363
+
364
+ nic_vport_ctx = MLX5_ADDR_OF (query_nic_vport_context_out , out ,
365
+ nic_vport_context );
366
+ req_list_size = MLX5_GET (nic_vport_context , nic_vport_ctx ,
367
+ allowed_list_size );
368
+
369
+ * size = req_list_size ;
370
+ for (i = 0 ; i < req_list_size ; i ++ ) {
371
+ void * vlan_addr = MLX5_ADDR_OF (nic_vport_context ,
372
+ nic_vport_ctx ,
373
+ current_uc_mac_address [i ]);
374
+ vlans [i ] = MLX5_GET (vlan_layout , vlan_addr , vlan );
375
+ }
376
+ out :
377
+ kfree (out );
378
+ return err ;
379
+ }
380
+ EXPORT_SYMBOL_GPL (mlx5_query_nic_vport_vlans );
381
+
382
+ int mlx5_modify_nic_vport_vlans (struct mlx5_core_dev * dev ,
383
+ u16 vlans [],
384
+ int list_size )
385
+ {
386
+ u32 out [MLX5_ST_SZ_DW (modify_nic_vport_context_out )];
387
+ void * nic_vport_ctx ;
388
+ int max_list_size ;
389
+ int in_sz ;
390
+ void * in ;
391
+ int err ;
392
+ int i ;
393
+
394
+ max_list_size = 1 << MLX5_CAP_GEN (dev , log_max_vlan_list );
395
+
396
+ if (list_size > max_list_size )
397
+ return - ENOSPC ;
398
+
399
+ in_sz = MLX5_ST_SZ_BYTES (modify_nic_vport_context_in ) +
400
+ list_size * MLX5_ST_SZ_BYTES (vlan_layout );
401
+
402
+ memset (out , 0 , sizeof (out ));
403
+ in = kzalloc (in_sz , GFP_KERNEL );
404
+ if (!in )
405
+ return - ENOMEM ;
406
+
407
+ MLX5_SET (modify_nic_vport_context_in , in , opcode ,
408
+ MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT );
409
+ MLX5_SET (modify_nic_vport_context_in , in ,
410
+ field_select .addresses_list , 1 );
411
+
412
+ nic_vport_ctx = MLX5_ADDR_OF (modify_nic_vport_context_in , in ,
413
+ nic_vport_context );
414
+
415
+ MLX5_SET (nic_vport_context , nic_vport_ctx ,
416
+ allowed_list_type , MLX5_NVPRT_LIST_TYPE_VLAN );
417
+ MLX5_SET (nic_vport_context , nic_vport_ctx ,
418
+ allowed_list_size , list_size );
419
+
420
+ for (i = 0 ; i < list_size ; i ++ ) {
421
+ void * vlan_addr = MLX5_ADDR_OF (nic_vport_context ,
422
+ nic_vport_ctx ,
423
+ current_uc_mac_address [i ]);
424
+ MLX5_SET (vlan_layout , vlan_addr , vlan , vlans [i ]);
425
+ }
426
+
427
+ err = mlx5_cmd_exec_check_status (dev , in , in_sz , out , sizeof (out ));
428
+ kfree (in );
429
+ return err ;
430
+ }
431
+ EXPORT_SYMBOL_GPL (mlx5_modify_nic_vport_vlans );
432
+
321
433
int mlx5_query_hca_vport_gid (struct mlx5_core_dev * dev , u8 other_vport ,
322
434
u8 port_num , u16 vf_num , u16 gid_index ,
323
435
union ib_gid * gid )
0 commit comments