@@ -268,10 +268,11 @@ struct virtchnl_vf_resource {
268
268
u32 rss_key_size ;
269
269
u32 rss_lut_size ;
270
270
271
- struct virtchnl_vsi_resource vsi_res [1 ];
271
+ struct virtchnl_vsi_resource vsi_res [];
272
272
};
273
273
274
- VIRTCHNL_CHECK_STRUCT_LEN (36 , virtchnl_vf_resource );
274
+ VIRTCHNL_CHECK_STRUCT_LEN (20 , virtchnl_vf_resource );
275
+ #define virtchnl_vf_resource_LEGACY_SIZEOF 36
275
276
276
277
/* VIRTCHNL_OP_CONFIG_TX_QUEUE
277
278
* VF sends this message to set up parameters for one TX queue.
@@ -340,10 +341,11 @@ struct virtchnl_vsi_queue_config_info {
340
341
u16 vsi_id ;
341
342
u16 num_queue_pairs ;
342
343
u32 pad ;
343
- struct virtchnl_queue_pair_info qpair [1 ];
344
+ struct virtchnl_queue_pair_info qpair [];
344
345
};
345
346
346
- VIRTCHNL_CHECK_STRUCT_LEN (72 , virtchnl_vsi_queue_config_info );
347
+ VIRTCHNL_CHECK_STRUCT_LEN (8 , virtchnl_vsi_queue_config_info );
348
+ #define virtchnl_vsi_queue_config_info_LEGACY_SIZEOF 72
347
349
348
350
/* VIRTCHNL_OP_REQUEST_QUEUES
349
351
* VF sends this message to request the PF to allocate additional queues to
@@ -385,10 +387,11 @@ VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_vector_map);
385
387
386
388
struct virtchnl_irq_map_info {
387
389
u16 num_vectors ;
388
- struct virtchnl_vector_map vecmap [1 ];
390
+ struct virtchnl_vector_map vecmap [];
389
391
};
390
392
391
- VIRTCHNL_CHECK_STRUCT_LEN (14 , virtchnl_irq_map_info );
393
+ VIRTCHNL_CHECK_STRUCT_LEN (2 , virtchnl_irq_map_info );
394
+ #define virtchnl_irq_map_info_LEGACY_SIZEOF 14
392
395
393
396
/* VIRTCHNL_OP_ENABLE_QUEUES
394
397
* VIRTCHNL_OP_DISABLE_QUEUES
@@ -459,10 +462,11 @@ VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr);
459
462
struct virtchnl_ether_addr_list {
460
463
u16 vsi_id ;
461
464
u16 num_elements ;
462
- struct virtchnl_ether_addr list [1 ];
465
+ struct virtchnl_ether_addr list [];
463
466
};
464
467
465
- VIRTCHNL_CHECK_STRUCT_LEN (12 , virtchnl_ether_addr_list );
468
+ VIRTCHNL_CHECK_STRUCT_LEN (4 , virtchnl_ether_addr_list );
469
+ #define virtchnl_ether_addr_list_LEGACY_SIZEOF 12
466
470
467
471
/* VIRTCHNL_OP_ADD_VLAN
468
472
* VF sends this message to add one or more VLAN tag filters for receives.
@@ -481,10 +485,11 @@ VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_ether_addr_list);
481
485
struct virtchnl_vlan_filter_list {
482
486
u16 vsi_id ;
483
487
u16 num_elements ;
484
- u16 vlan_id [1 ];
488
+ u16 vlan_id [];
485
489
};
486
490
487
- VIRTCHNL_CHECK_STRUCT_LEN (6 , virtchnl_vlan_filter_list );
491
+ VIRTCHNL_CHECK_STRUCT_LEN (4 , virtchnl_vlan_filter_list );
492
+ #define virtchnl_vlan_filter_list_LEGACY_SIZEOF 6
488
493
489
494
/* This enum is used for all of the VIRTCHNL_VF_OFFLOAD_VLAN_V2_CAPS related
490
495
* structures and opcodes.
@@ -1372,11 +1377,19 @@ VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
1372
1377
#define __vss_byone (p , member , count , old ) \
1373
1378
(struct_size(p, member, count) + (old - 1 - struct_size(p, member, 0)))
1374
1379
1380
+ #define __vss_full (p , member , count , old ) \
1381
+ (struct_size(p, member, count) + (old - struct_size(p, member, 0)))
1382
+
1375
1383
#define __vss (type , func , p , member , count ) \
1376
1384
struct type: func(p, member, count, type##_LEGACY_SIZEOF)
1377
1385
1378
1386
#define virtchnl_struct_size (p , m , c ) \
1379
1387
_Generic(*p, \
1388
+ __vss(virtchnl_vf_resource, __vss_full, p, m, c), \
1389
+ __vss(virtchnl_vsi_queue_config_info, __vss_full, p, m, c), \
1390
+ __vss(virtchnl_irq_map_info, __vss_full, p, m, c), \
1391
+ __vss(virtchnl_ether_addr_list, __vss_full, p, m, c), \
1392
+ __vss(virtchnl_vlan_filter_list, __vss_full, p, m, c), \
1380
1393
__vss(virtchnl_rss_key, __vss_byone, p, m, c), \
1381
1394
__vss(virtchnl_rss_lut, __vss_byone, p, m, c))
1382
1395
@@ -1414,24 +1427,23 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
1414
1427
valid_len = sizeof (struct virtchnl_rxq_info );
1415
1428
break ;
1416
1429
case VIRTCHNL_OP_CONFIG_VSI_QUEUES :
1417
- valid_len = sizeof ( struct virtchnl_vsi_queue_config_info ) ;
1430
+ valid_len = virtchnl_vsi_queue_config_info_LEGACY_SIZEOF ;
1418
1431
if (msglen >= valid_len ) {
1419
1432
struct virtchnl_vsi_queue_config_info * vqc =
1420
1433
(struct virtchnl_vsi_queue_config_info * )msg ;
1421
- valid_len += (vqc -> num_queue_pairs *
1422
- sizeof (struct
1423
- virtchnl_queue_pair_info ));
1434
+ valid_len = virtchnl_struct_size (vqc , qpair ,
1435
+ vqc -> num_queue_pairs );
1424
1436
if (vqc -> num_queue_pairs == 0 )
1425
1437
err_msg_format = true;
1426
1438
}
1427
1439
break ;
1428
1440
case VIRTCHNL_OP_CONFIG_IRQ_MAP :
1429
- valid_len = sizeof ( struct virtchnl_irq_map_info ) ;
1441
+ valid_len = virtchnl_irq_map_info_LEGACY_SIZEOF ;
1430
1442
if (msglen >= valid_len ) {
1431
1443
struct virtchnl_irq_map_info * vimi =
1432
1444
(struct virtchnl_irq_map_info * )msg ;
1433
- valid_len += (vimi -> num_vectors *
1434
- sizeof ( struct virtchnl_vector_map ) );
1445
+ valid_len = virtchnl_struct_size (vimi , vecmap ,
1446
+ vimi -> num_vectors );
1435
1447
if (vimi -> num_vectors == 0 )
1436
1448
err_msg_format = true;
1437
1449
}
@@ -1442,23 +1454,24 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
1442
1454
break ;
1443
1455
case VIRTCHNL_OP_ADD_ETH_ADDR :
1444
1456
case VIRTCHNL_OP_DEL_ETH_ADDR :
1445
- valid_len = sizeof ( struct virtchnl_ether_addr_list ) ;
1457
+ valid_len = virtchnl_ether_addr_list_LEGACY_SIZEOF ;
1446
1458
if (msglen >= valid_len ) {
1447
1459
struct virtchnl_ether_addr_list * veal =
1448
1460
(struct virtchnl_ether_addr_list * )msg ;
1449
- valid_len += veal -> num_elements *
1450
- sizeof ( struct virtchnl_ether_addr );
1461
+ valid_len = virtchnl_struct_size ( veal , list ,
1462
+ veal -> num_elements );
1451
1463
if (veal -> num_elements == 0 )
1452
1464
err_msg_format = true;
1453
1465
}
1454
1466
break ;
1455
1467
case VIRTCHNL_OP_ADD_VLAN :
1456
1468
case VIRTCHNL_OP_DEL_VLAN :
1457
- valid_len = sizeof ( struct virtchnl_vlan_filter_list ) ;
1469
+ valid_len = virtchnl_vlan_filter_list_LEGACY_SIZEOF ;
1458
1470
if (msglen >= valid_len ) {
1459
1471
struct virtchnl_vlan_filter_list * vfl =
1460
1472
(struct virtchnl_vlan_filter_list * )msg ;
1461
- valid_len += vfl -> num_elements * sizeof (u16 );
1473
+ valid_len = virtchnl_struct_size (vfl , vlan_id ,
1474
+ vfl -> num_elements );
1462
1475
if (vfl -> num_elements == 0 )
1463
1476
err_msg_format = true;
1464
1477
}
0 commit comments